Skip to main content
Introducing the Automate SDK! Get your entire test suite running on BrowserStack in minutes! Learn More.

Run Serenity Tests in Parallel

On BrowserStack, you can run multiple Serenity 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.

With Parallel Testing, you can run the same test on different browser/device combinations i.e. cross-browser testing, or run different tests on the same or different browser/device combinations. Parallel Testing will help you reduce the run time of your test suite, resulting in faster build times and faster releases.

Run sample test in parallel

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

     git clone -b selenium-4 https://github.com/browserstack/serenity-browserstack.git
     cd serenity-browserstack
    
  2. Install the dependencies using the following command (if not already done):

     mvn install
    
  3. Update serenity.properties file within the serenity-browserstack directory with your BrowserStack credentials and browsers list to execute the test on multiple browsers in parallel as shown below:

    serenity.properties
     webdriver.driver = provided
     webdriver.provided.type = mydriver
     webdriver.provided.mydriver = com.browserstack.BrowserStackSerenityDriver
     serenity.driver.capabilities = mydriver
    
     browserstack.user=YOUR_USERNAME
     browserstack.key=YOUR_ACCESS_KEY
     browserstack.server=hub-cloud.browserstack.com
     browserstack.name=[Serenity] Parallel Test
    
     environment.parallel_1.browser=chrome
     environment.parallel_2.browser=firefox
     environment.parallel_3.browser=safari
     environment.parallel_4.browser=ie
    
  4. Capabilities for each environment can be customized. For example:

    environment.parallel_1.browser=chrome
    environment.parallel_1.browser_version=latest
    environment.parallel_1.os=Windows
    environment.parallel_1.os_version=10
    environment.parallel_1.resolution=2048x1536
    
    # Similarly, other custom capabilities can be added for other environments also
    
  5. Parallel test cases need to be written for running in parallel with Serenity within serenity-browserstack/src/test/java/com/browserstack/cucumber/ directory. The following files already exist in the sample repository. We will run the parallel tests in the next step.

    ParallelChromeTest.java
     @RunWith(CucumberWithSerenity.class)
     @CucumberOptions(features="src/test/resources/features/single.feature")
     public class ParallelChromeTest extends BrowserStackSerenityTest { }
    
    ParallelFirefoxTest.java
     @RunWith(CucumberWithSerenity.class)
     @CucumberOptions(features="src/test/resources/features/single.feature")
     public class ParallelFirefoxTest extends BrowserStackSerenityTest { }
    
  6. You can now run your tests in parallel on BrowserStack using the following command:

     mvn verify -P parallel	    
    
Note: 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 an Expert
Download Copy