How To Perform Parallel Test Execution In TestNG

Didem TEMEL
2 min readJun 14, 2022

--

In this medium post, we will look at how the TestNG XML file can be used for parallel test execution.

TestNG Framework is designed in JAVA language as an open source automation testing framework. This framework is preferred for its ease of using multiple annotations, grouping, dependence, prioritization and parametrization features.

What is Parallel Testing?

Parallel testing is a process of running the test cases in parallel rather than one after the other. In parallel testing, the program’s multiple parts execute together to reduce the overall execution time. For example, if a test takes 1 minute to complete a single test execution, it will take 10 minutes to run ten tests one after another. However, overall test execution will take 1 minute (or less) when the same test suite run in parallel.

What is TestNG XML file?

TestNG XML file is a test suite configuration file that helps us to create, run and handle multiple test classes, define test suites and tests, set test dependency, include or exclude any test, method, class or package.

In my last article in API Testing with Rest Assured, I created a TestNG XML file for Rick And Morty API project. In my project, I have used Rest Assured Framework for testing the API and integrated with TestNG framework to automate all my test cases. I have implemented these methods inside the TestNG classes using @test methods. I have used < suite > tag to specify the suite name, < test > tag to specify the test name and < classes > tag to add < class > tags where test classes’ names are given.

Parallel test execution in TestNG is triggered with the help of keyword “parallel”. In my case, I am going to use “methods” value since I am aiming towards the execution of the parallel methods but we can also use classes and tests.

Threads in parallel testing refer to different parts in which the test execution will be divided and run in parallel. By using “thread-count”, we can determine the number of threads we want to run while performing parallel testing.

Here in this article, we have used testing.xml file to run our TestNG tests in parallel. See you in my next article, till then happy testing!

References

  1. https://testng.org/doc/documentation-main.html
  2. https://www.guru99.com/all-about-testng-and-selenium.html

--

--