Tuesday, August 7, 2018

How to execute classes in parallel in TestNG?

In the previous post How to execute test methods in parallel in TestNG? we have seen executing the test cases/test methods of a class in parallel. In this post we will learn about executing the classes in parallel. A class will contain one or more test cases/test methods.

To execute the classes in parallel, we need to set parallel = "classes" in the 'suite' tag in the testng.xml file and set thread-count = "2", this count depends on our requirement. Please check the screenshot below

Class One: In the below class 'regressionSetOne.java' we have two @test methods

Class Two: In the below class 'regressionSetTwo.java' we have another two@test methods

Create a testng.xml file as shown in the below screenshot

if we execute the above testng.xml file, first tests in the regressionSetOne will be executed then regressionSetTwo tests sequentailly. We all knew that.

To execute the classes in parallel, put parallel = "classes" and thread-count = "2" in testng.xml as shown in the below screenshot.

Check the below results, the two classes are started at the same time and tests are executed almost in parallel.

Thanks for reading. Please comment your queries or suggestions on this post. #HappyLearing #HappyTesting #qababu

No comments:

Post a Comment

Katalon 08: Integration of HP ALM with Katalon Studio

In this post, this post we discuss about integration of  HP ALM with Katalon Studio. If we can integrate HP ALM with Katalon we can update ...