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

Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...