Running tests in parallel
So far we have managed to get our tests cycling through different machines. We also got it working against the Selenium Grid hub so that we can see all of our tests being split out to the machines and make sure that we test against browser and operating system combinations.
In this section, we will look at how we can add a thread-count attribute to the <suite>
node in our test configuration file. We will also need to add the parallel attribute to the test suite. The value that it takes will either be methods or classes. This will mean that either the methods—the test cases—are run in parallel, or the classes that contain the test cases are running in parallel.
Getting our tests running in parallel
Now, we are ready to have our tests running in parallel:
Open your
TestNG
XML configuration file.Add
parallel=methods
to the suite node.Add
thread-count=3
to the suite node. This will run your tests with three threads. This number can be any value that you want. It is...