I'm using below code to dynamically load and run, testng.xml suites via, tCaseName variable(who's value is coming from excel file).
I have 2 testng.xml files, who's name i have renamed to some meaningfull names like loginTest.xml and ValidationTest.xml. these xml files are created from test.java files-->Convert to TestNG options.
now the issue is, when below code run's in the loop then the tCaseName value changes from row 1 of excel to row 2. It works fine and picks up correct loginTest.xml in first iteration, however in second iteration, tCaseName value changes to ValidationTest.xml, however TestNG still runs loginTest.xml. tCaseName variable values changes correctly, and there is no issue is getting this value from excel as i have checked that in watch window. However still due to some reason it just runs loginTest.xml.
if i change the order in excel like 'ValidationTest' being in first row and 'loginTest' being second, then it just runs ValidationTest.xml in every iteration. Please suggest.
List<String> suites = new ArrayList<String>(); suites.add(tCaseName+".xml"); //Set the suites to run tngObj.setTestSuites(suites); //Call the run method to run the suit. tngObj.run();