I set up my tests where each row in the dataProvider
creates a new instance of the test class and runs some tests with the data passed in. I want to have all the tests execute simultaneously, however when I run the tests with the current setup, test a
is instantiated and the first method is run, then test b
is instantiated and the first method is run, etc.
I want to be able to have tests a,b,c
all execute at once side by side without waiting for eachother to finish/move in a stepwise fashion.
I've achieved this parallel behavior by creating 3 separate class files with individual dataproviders with one row of unique data and then calling parallel="classes"
, but how would I do it all in one class?
public class Class1 {
@DataProvider(name = "provider", parallel = true)
public static Object[][] dataProviderSetup() {
return new Object[][] { { "a", "1", "first" }, { "b", "2", "second" }, { "c", "3", "third" } };
}
@Factory(dataProvider="provider")
public Class1(String var1, String var2, String var3) {
this.var1 = var1;
this.var2 = var2;
this.var3 = var3;
}
@Test()
public void f1() {
//
}
}
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="suite1" verbose="1" preserve-order="true" data-provider-thread-count="3">
<test name="test1" preserve-order="true">
<classes>
<class name="package.Class1" />
</classes>
</test>