How to run 2 testNG xml suites in sequential mode or parallel mode using batch file?
Let us consider below to be the content of 2 Test NG xmls
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="mySuite1" thread-count="3">
<test name = "myTest">
<classes>
<class name="testNG.Test1"/>
</classes>
</test>
</suite>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="mySuite2" thread-count="3">
<test name = "myTest2">
<classes>
<class name="testNG.Test2"/>
</classes>
</test>
</suite>
To run these 2 xmls in sequence, we can write a batch file with below content:
set classpath="Path of Test NG libs\*;
cd directory classpath of TestNG class files
java org.testng.TestNG TestNG_Parallel.xml TestNG_Parallel2.xml
Note here command java org.testng.TestNG xml1 xml2 will run suites in sequence.
classpath = Here you need to set path of all libs that you are using in project.
cd directory must point to the class files path.
Here is the sample output:
Thread ID ------------1
test1
===============================================
mySuite1
Total tests run: 1, Failures: 0, Skips: 0
===============================================
Thread ID ------------1
test2
Thread ID ------------1
test3
===============================================
mySuite2
Total tests run: 2, Failures: 0, Skips: 0
===============================================
Note the Thread ID same for all tests because same thread was used for execution (Sequential).
Now to run 2 xml suites in parallel just add -suitethreadpoolsize 2 option. So batch file would like like this:
set classpath="Path of Test NG libs\*;
cd directory classpath of TestNG class files
java org.testng.TestNG -suitethreadpoolsize 2 TestNG_Parallel.xml TestNG_Parallel2.xml
Below is the sample output:
Thread ID ------------9
Thread ID ------------8
test1
test2
Thread ID ------------9
test3
===============================================
mySuite2
Total tests run: 2, Failures: 0, Skips: 0
===============================================
===============================================
mySuite1
Total tests run: 1, Failures: 0, Skips: 0
===============================================
Note the Thread ID is different for some tests because execution happened in parallel ( 8 and 9 ).
Hope this blog has been useful to you.
Youtube channel: https://www.youtube.com/user/srinivaskinik
Facebook page: https://www.facebook.com/srinivaskinikalmady/
No comments:
Post a Comment