Run Parallel Execution on Selenum Grid
Asked Answered
O

1

8
<?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

Orthochromatic answered 8/10, 2018 at 12:39 Comment(0)
R
9

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.

Rhapsodic answered 11/10, 2018 at 5:3 Comment(2)
I have tried parallel = tests. Browsers opens in the different nodes. but commands are going to only one node which opens the browser latest. Eg., i wanted to enter the username field.. In the same node it enters twice..Orthochromatic
that was due to driver issue.. I have fixed.. thanks for the answerOrthochromatic

© 2022 - 2024 — McMap. All rights reserved.