2

I was looking at https://sourceforge.net/projects/testngdatabind/ and searched for the possibility to set the properties location on start up of the tests. The usecase is that I have more environments (e.g. different databases) where I want to run the same tests.

There are two different properties files in the TestNG databinding. The first (called data properties file) defines the type of data source ('properties in my case) and the URL of actual key/value pairs used by the test (called Properties Data Source). But none of them accepts variable passed to the test through e.g. system environment variable.

Even if TestNG databinding framework is not developed for ~6 years it works quite well. Is there any alternative how to make TestNG tests generic so that they can be run on environments differing just by data used?

user861594
  • 5,733
  • 3
  • 29
  • 45

1 Answers1

0

As alternative, you can make use of TestNG extension QAF which provides different in-built data-providers and also has resource and environment management. With QAF if your test case is data driven and have different data for different environment it may look like below:

    @QAFDataProvider(dataFile = "resources/${env}/data/tc_01.json")
    @Test
    public void tc_01(Map<String, Object>){
    }

Value of ${env} in data file path can be provided at the time of execution in different ways.This is just as an example. There can be other alternative ways by using different features of qaf depending on need.

user861594
  • 5,733
  • 3
  • 29
  • 45