---Advertisement---

TestNG: How to Run Multiple Test Suites in Selenium Best 2025

By Manisha

Updated On:

---Advertisement---
TestNG

is a powerful framework that allows parallel execution of test methods, classes, and test cases. By running tests simultaneously in different threads, execution time is significantly reduced, improving efficiency.

In this guide, we will walk through:
✅ Creating a XML file for executing multiple test suites
✅ Running test cases in parallel
✅ Using key attributes like thread-count, parallel, and verbose


👉Step 1: Creating a TestNG XML File

To execute multiple test suites using follow these steps:

1. Set Up a New Java Project in Eclipse

  • Open Eclipse and create a new Java project.
  • Install the plugin (if not installed).

2. Create Packages for Test Suites

Inside the project, create two packages:

  • com.suite1
  • com.suite2

3. Create Java Classes for Test Execution

Inside each package, create a Java class with test methods.

👉Flipkart.java (Inside com.suite1)

java package com.suite1;
import org.testng.annotations.Test;

public class Flipkart {
@Test
public void openFlipkart() {
System.out.println("Flipkart test case executed");
}
}

👉Snapdeal.java (Inside com.suite2)

javapackage com.suite2;
import org.testng.annotations.Test;

public class Snapdeal {
@Test
public void openSnapdeal() {
System.out.println("Snapdeal test case executed");
}
}

Create a new file in your project and name it
This XML file configures and manages test execution.


👉Step 2: Parallel Execution in

Now, let’s configure to run multiple test suites in parallel.

xml<suite name="E-commerce Suite" parallel="classes" thread-count="2">  
<test name="Flipkart Test">
<classes>
<class name="com.suite1.Flipkart"/>
</classes>
</test>

<test name="Snapdeal Test">
<classes>
<class name="com.suite2.Snapdeal"/>
</classes>
</test>
</suite>
  1. thread-count="2" → Defines the number of threads for parallel execution.
  2. parallel="classes" → Runs test cases in parallel at the class level.
  3. verbose="1-10" → Increases logging detail in the console output.

👉Step 3: Running XML File

  1. Right-click on testng.xml.
  2. Select Run As → Suite.
  3. The test execution will begin, and you’ll see output in the console.

Expected Console Output:

bash Flipkart test case executed  
Snapdeal test case executed

This confirms that both test cases were executed simultaneously.


👉Conclusion

makes it easy to run multiple test suites in parallel, reducing execution time and improving efficiency.

✅ Run multiple test suites using a single XML configuration.
✅ Execute tests in parallel using thread-count and parallel attributes.
✅ Optimize Selenium with faster execution times.

Start using parallel execution today to improve your Selenium test automation!

Parallel Execution in Selenium
Testing Selenium Download

Leave a Comment

Index