How to run multiple test cases using TestNG Test Suite in Selenium?

We can run multiple test cases using TestNG test suite in Selenium webdriver. To execute test cases simultaneously, we have to enable parallel execution in TestNG.

A TestNG execution is driven by the TestNG xml file. To trigger parallel execution we have to use the attributes – parallel and thread-count. The attribute threadcount controls the number of threads to be triggered while executing the tests in a parallel mode. The values that can be set for parallel attributes are – tests, classes, instances and methods.


import org.testng.annotations.Test;
public class TestNG15 {
   public void tC1() {
      System.out.println("Test Case 1");
   public void tC2() {
      System.out.println("Test Case 2");
   public void tC3() {
      System.out.println("Test Case 3");
   public void tC4() {
      System.out.println("Test Case 4");

TestNG XML Implementation.

<!DOCTYPE suite SYSTEM "" >
<!—parallel methods set for execution with 2 threads-->
<suite name="Test-Suite" parallel="methods" thread-count="2">
   <test name="Tutorialspoint" >
         <class name="TestNG15" />


TestNG report in html format obtained from project folder test-output→index.html.

Updated on: 07-Apr-2021

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started