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


Testng xml file.

<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "" >
<suite name = "Tutorialspoint Test" parallel ="tests" thread-count= ="5">
   <test name = "Test Cycle 1">
            <include name = "Smoke"/>
         <class name = "TestQA" />

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

Updated on: 11-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started