Run TestNG Tests in Parallel

On BrowserStack, you can run multiple TestNG tests at the same time across various browser, device and OS combinations. This is Parallel Testing. Parallel Testing gives you the same benefits as running a multi-threaded application and helps you reduce the run time of your test suite, resulting in faster build times and faster releases.

To run tests on multiple browsers in parallel with TestNG on BrowserStack Automate, follow the below steps:

  1. Clone the testng-browserstack repo on GitHub (if not already done):

     git clone https://github.com/browserstack/testng-browserstack.git
     cd testng-browserstack
    
  2. Install the dependencies using the following command:

     mvn compile
    
  3. Update parallel.conf.json files within the testng-browserstack/src/test/resources/conf directory with your BrowserStack credentials as shown below:

    parallel.conf.json
     {
       "server": "hub-cloud.browserstack.com",
       "user": "YOUR_USERNAME",
       "key": "YOUR_ACCESS_KEY",
       "capabilities": {
         "build": "testng-browserstack",
         "name": "Bstack-[TestNG] Parallel Test",
         "browserstack.debug": true
       },
       "environments": {
         "chrome": {
           "browser": "chrome"
         },
         "firefox": {
           "browser": "firefox"
         },
         "safari": {
           "os": "OS X",
           "browser": "safari"
         },
         "ie": {
           "browser": "internet explorer"
         }
       }
     }
    
  4. You can now run your tests in parallel on BrowserStack using the following command:

     mvn test -P parallel	    
    
Note: For your parallel tests to run, the parallel.testng.xml file within the testng-browserstack/config directory of the sample repository is also needed. Remember to use the same structure when you port your own tests to run on BrowserStack.

You can achieve your test coverage and build execution time goals by using our calculator to understand how many parallel sessions you need.

We're sorry to hear that. Please share your feedback so we can do better






Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better






Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to automation expert