Parallel Test

Home >> Tags >> Parallel Test

Configure parallel execution of tests using TestNG selenium

In testing, it is always important to test application in different browsers. We can perform automation on multiple browsers using selenium and testng. If there are more number of tests that need to be executed in parallel on different browsers also, we can do this using testng. And there is an other challenging task such executing tests in different browser versions and also different Operating systems. This can be achieved with Selenium Grid.

Parallel Execution of Classes in TestNG

TestNG provides an ability to run test classes in parallel. By using parallel execution of classes, each class will be started and executed simultaneously in different threads.

Let us look at basic example for Parallel Execution of Classes using testng.xml.

We will create a Two classes with Two test methods each and try to execute in different threads.

Create class and name it as :

Parallel Execution of test methods in TestNG

TestNG provides multiple ways to execute tests in separate threads. In testng.xml, if we set 'parallel' attribute on the tag to 'tests', testNG will run all the ‘@Test’ methods in tag in the same thread, but each tag will be in a separate thread.

If we want to run methods/classes in separate threads, we need to set 'parallel' attribute on the tag to 'methods' / 'classes'