I have a usecase where I have to run certain test methods under one class dynamically.
I am using @factory
annotation for generating these test classes dynamically.
I already have my test methods under the mentioned class running in parallel.
How do I make the test classes and test methods both parallel? Is there anyway to do it as well?
public class FactoryClass {
@Factory
public Object[] factoryMethod() {
return new Object[] { new TestClass(), new TestClass() }
}
}
public class TestClass {
@DataProvider(name = "firstDataProvider", parallel = true)
public Object[] firstDataProvider() {
return new Object[] { };
}
@DataProvider(name = "secondDataProvider", parallel = true)
public Object[] secondDataProvider() {
return new Object[] { };
}
@Test(dataProvider = "firstDataProvider")
public void firstTestMethod(String arg) {
}
@Test(dataProvider = "secondDataProvider")
public void secondTestMethod(String arg) {
}
}
test.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" parallel="methods" data-provider-thread-count="60">
<test name="test1">
<classes>
<class name="com.amriteya.test.FactoryMain"></class>
</classes>
</test>
</suite>
Following is the layout of my classes.
In test.xml
I am setting parallel="methods" but it is not providing the right output for me.