I have a TestNG @Factory Class, a Base class which creates the drivers and two test class that contain multiple @Test methods to run the tests. Given my @Factory class below.
public class SampleFactory {
@Factory(dataProvider="DeviceDetails")
public synchronized Object[] factoryMethod(String deviceID){
return new Object[] {new IndTest(deviceID),new IndTestTwo(deviceID)};
}
@DataProvider(name="DeviceDetails",parallel=true)
public Object[][] passDeviceID(){
return new Object[][] {{"02157DF2DA5A1C09"},{"D5588B67"}};
}
}
IndTest
and IndTest2
are the two test classes. They extend the Base Class and call the Base class constructor to create the drivers. Only one instance of the driver can be used at a particular time for a particular deviceID.
The problem I am facing is that both IndTest and IndTest2 are being run at the same time the tests try to run different tests on particular device at the same time. I require the IndTest class to be called first and run the tests inside that class on device 1 and device 2 and then move to IndTest2 and carry out the same sort of execution. Below is the TestNG xml that I use currently.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Test_Suite" skipfailedinvocationcounts="false" junit="false" parallel="classes"
data-provider-thread-count="100" annotations="JDK" group-by-instances="true"/>
Awaiting your ideas :)
Looks like you need to tweak the TestNG.xml a little bit. Give the following a shot
However, test dependencies are often consider as bad practice. All the tests should be independent so that they can provide you intelligent feedback without depending on the order of execution.