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
- 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
- Install the dependencies using the following command (if not already done):
mvn install
-
Update
serenity.properties
file within theserenity-browserstack
directory with your BrowserStack credentials and browsers list to execute the test on multiple browsers in parallel as shown below:serenity.propertieswebdriver.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
- 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
-
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 { }
- You can now run your tests in parallel on BrowserStack using the following command:
mvn verify -P parallel
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
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!