I want to run my automation suite (implemented using Selenium Webdriver (Java) + TestNG + Maven) in parallel against multiple browser capabilities. I can run it in parallel for different capabilities using below sample testng.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" name="Functional Test Suite" parallel="tests">
<test name="Windows-FF-37.0" preserve-order="true" >
<parameter name="browser" value="Firefox"/>
<parameter name="version" value="37.0"/>
<parameter name="os" value="Windows"/>
<parameter name="os_version" value="8.1"/>
<parameter name="device" value=""/>
<classes>
<class name="uat.mycompany.tests.FirstTest"/>
<class name="uat.mycompany.tests.SecondTest"/>
<class name="uat.mycompany.tests.ThirdTest"/>
<class name="uat.mycompany.tests.FourthTest"/>
</classes>
</test>
<test name="MAC-Yosemite-Chrome-36.0" preserve-order="true">
<parameter name="browser" value="Chrome"/>
<parameter name="version" value="36.0"/>
<parameter name="os" value="OS X"/>
<parameter name="os_version" value="Yosemite"/>
<parameter name="device" value=""/>
<classes>
<class name="uat.mycompany.tests.FirstTest"/>
<class name="uat.mycompany.tests.SecondTest"/>
<class name="uat.mycompany.tests.ThirdTest"/>
<class name="uat.mycompany.tests.FourthTest"/>
</classes>
</test>
</suite>
But when I run this testng.xml, it starts with 'FirstTest' on both VMs; one with Chrome+Mac & another with Forefox+Windows configuration. I DO NOT want this, because the data modified by one script fails another script.
My requirement is to run all classes from one node in parallel and nodes in sequence. As a work around, I can always put classes name in different order in different test nodes, but since I am having hundreds of test classes, it is not feasible solution.
Also, eventually I want to set up these parameters through some properties file so that I can manage the run environments easily.
You can follow the below steps:
thread-count="4" parallel="classes"
First XML file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" name="Functional Test Suite1" parallel="classes">
<test name="Windows-FF-37.0" preserve-order="true" >
<parameter name="browser" value="Firefox"/>
<parameter name="version" value="37.0"/>
<parameter name="os" value="Windows"/>
<parameter name="os_version" value="8.1"/>
<parameter name="device" value=""/>
<classes>
<class name="uat.mycompany.tests.FirstTest"/>
<class name="uat.mycompany.tests.SecondTest"/>
<class name="uat.mycompany.tests.ThirdTest"/>
<class name="uat.mycompany.tests.FourthTest"/>
</classes>
</test>
</suite>
Second XML file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" name="Functional Test Suite2" parallel="classes">
<test name="MAC-Yosemite-Chrome-36.0" preserve-order="true">
<parameter name="browser" value="Chrome"/>
<parameter name="version" value="36.0"/>
<parameter name="os" value="OS X"/>
<parameter name="os_version" value="Yosemite"/>
<parameter name="device" value=""/>
<classes>
<class name="uat.mycompany.tests.FirstTest"/>
<class name="uat.mycompany.tests.SecondTest"/>
<class name="uat.mycompany.tests.ThirdTest"/>
<class name="uat.mycompany.tests.FourthTest"/>
</classes>
</test>
</suite>
Third XML file (Need to execute this file):
<suite name="suite of suites">
<suite-files>
<suite-file path="Functional Test Suite1.xml" />
<suite-file path="Functional Test Suite2.xml" />
</suite-files>
</suite>