How to achieve parallel execution in TestNG?


We can achieve parallel execution with the help of TestNG. There is a parallel attribute in TestNG which is used for this implementation. The parallel execution in TestNG is associated with another attribute called thread-count.

The parallel attribute can have the values listed below −

  • Methods.

  • Classes.

  • Instances

  • Tests

Example

Testng xml file.

<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name = "Tutorialspoint Test" parallel ="tests" thread-count= ="5">
   <test name = "Test Cycle 1">
      <groups>
         <run>
            <include name = "Smoke"/>
         </run>
      </groups>
      <classes>
         <class name = "TestQA" />
      </classes>
   </test>
</suite>

The execution will trigger in parallel mode for tests with the thread count of 5.

Updated on: 11-Jun-2020

522 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements