When using a DataProvider with multiple TestNG methods, each method starts with all the data sets in the sequence. Instead, I want to iterate over datasets and execute all the methods on each iteration. I do not care if the results show each test result or a summary of the runs by the method.
I have already tried the option
order-by-instances="true"
in suite.xml without success.
Code example:
public class TestNGTest
{
@DataProvider(name = "dp")
public Object[][] createData(Method m) {
return new Object[][] { new Object[] { "Cedric" }, new Object[] {"Martina"}};
}
@Test(dataProvider = "dp")
public void test1(String s) throws InterruptedException {
System.out.println("test1 " + s);
Thread.sleep(1000);
}
@Test(dataProvider = "dp")
public void test2(String s) throws InterruptedException {
System.out.println("test2 " + s);
Thread.sleep(1000);
}
}
Actual result:
test1 Cedric
test1 Martina
test2 Cedric
test2 Martina
PASSED: test1("Cedric")
PASSED: test1("Martina")
PASSED: test2("Cedric")
PASSED: test2("Martina")
Required Result:
test1 Cedric
test2 Cedric
test1 Martina
test2 Martina
PASSED: test1("Cedric")
PASSED: test2("Cedric")
PASSED: test1("Martina")
PASSED: test2("Martina")
source
share