<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Parallel test suite" parallel="classes" thread-count="2">
<test thread-count="1" name="Transactoin">
<parameter name="remoteurl" value="http://xx.xx.xxx.xxx:5555/wd/hub"></parameter>
<classes>
<class name="POM_Test.ATransactionTest"/>
</classes>
</test> <!-- Test -->
<test thread-count="1" name="MyAlerts">
<parameter name="remoteurl" value="http://xx.xx.xx.xxx:5556/wd/hub"></parameter>
<classes>
<class name="POM_Test.MyAlertsTest"/>
</classes>
</test>
</suite> <!-- Suite -->
ATransactionTest
Class
has 47
Test cases
MyAlertsTest
Class
has 40
Test cases.
I wanted to run both classes simulatneously
and MyAlertsTest should take remoteurl which is given in the parameter and ATransaction test should take remoteurl given the parameter.
But what happens is, ATransactionTest
runs first in Node1
once all test case completed MyAlerts
runs in Node2
. How to run simulatenously.
Thanks
Selenium Grid is one of the components of Selenium which allows users to run tests in parallel on multiple browsers, multiple operating systems, and machines. Running Tests in parallel reduce the time and cost of execution of tests and results in better ROI.
You can perform parallel test execution in TestNG or any other framework of your choice with Selenium. In this Selenium TestNG tutorial, we deep dive into the integral aspects of parallel testing in TestNG.
Allow Multi-Threaded Tests: Using the parallel execution in TestNG, we can allow multiple threads to run simultaneously on the test case providing independence in the execution of different components of the software.
Based on my understanding of the document, TestNG will respect the order of tests in your xml file.
Now, you want to run both classes in parallel so you have set parallel="classes"
which is correct. However, your tests will still run on a single thread, meaning if you have multiple classes in your test group then it 'll run them in parallel but all tests will run in series one after another.
To solve this issue, you can either add multiple classes under same test group:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Parallel test suite" parallel="classes" thread-count="2">
<test thread-count="2" name="Transactoin">
<parameter name="parameterName" value="parameterValue"></parameter>
<classes>
<class name="Class1"/>
<class name="Class2"/>
</classes>
</test>
</suite> <!-- Suite -->
Or as in your case you can set parallel option to tests:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Parallel test suite" parallel="tests" thread-count="2">
<test thread-count="1" name="Transactoin">
<parameter name="remoteurl" value="http://xx.xx.xxx.xxx:5555/wd/hub"></parameter>
<classes>
<class name="POM_Test.ATransactionTest"/>
</classes>
</test> <!-- Test -->
<test thread-count="1" name="MyAlerts">
<parameter name="remoteurl" value="http://xx.xx.xx.xxx:5556/wd/hub"></parameter>
<classes>
<class name="POM_Test.MyAlertsTest"/>
</classes>
</test>
</suite> <!-- Suite -->
I hope this fixes your issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With