Reputation: 574
I have my testng.xml file as follows:
<suite name="Excel Control File Suite Set"
thread-count="30" configfailurepolicy="continue">
<test name="Excel Test" parallel="instances">
<classes>
<class name="com.selenium.engine.TestRunner1">
</class>
</classes>
</test>
<test name="Excel Test 1" parallel="instances">
<classes>
<class name="com.selenium.engine.TestRunner2">
</class>
</classes>
</test>
</suite>
This file is calling my TestRunner1 first and getting all the test case instances and then calling TestRunner2, collecting all the instances and starting the execution with all the test instances together. How can I control the flow so that I run TestRunner1 first and once the execution is complete, I can start the TestRunner2 from the file. Please let me know if any more information is needed or if I am not clear.
Upvotes: 3
Views: 20265
Reputation: 147
Change parallel="instances" to parallel="methods" which will execute the methods of TestRunner1 and TestRunner2 parallely but TestRunner2 will be executed after completion of TestRunner1
required change :-
<test name="Excel Test" parallel="methods">
<classes>
<class name="com.selenium.engine.TestRunner1"> </class>
</classes>
</test>
<test name="Excel Test 1" parallel="methods">
<classes>
<class name="com.selenium.engine.TestRunner2"> </class>
</classes>
</test>
parallel="methods": TestNG will run all your test methods in separate threads. Dependent methods will also run in separate threads but they will respect the order that you specified.
parallel="tests": TestNG will run all the methods in the same tag in the same thread, but each tag will be in a separate thread. This allows you to group all your classes that are not thread safe in the same and guarantee they will all run in the same thread while taking advantage of TestNG using as many threads as possible to run your tests.
parallel="classes": TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.
parallel="instances": TestNG will run all the methods in the same instance in the same thread, but two methods on two different instances will be running in different threads.
Reference :-
TestNG Documentation on Parallel running
Upvotes: 3