Skip to content

About

Serenity BDD's Cucumber runner (CucumberWithSerenity) on JUnit 6 with Playwright, running on BrowserStack with the BrowserStack Java SDK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serenity-runner-playwright-browserstack

Serenity BDD's Cucumber runner (@RunWith(CucumberWithSerenity.class)) on JUnit 6 with Playwright, running on BrowserStack with the BrowserStack Java SDK.

BrowserStack Logo

Use this only if your project must keep CucumberWithSerenity. For new or migrating projects use serenity-playwright-browserstack, which needs no JUnit 4 and runs scenarios in parallel.

How this sample is set up

Part Role
JUnit Platform 6 Runs the JUnit 4 runner classes SampleTest and LocalTest through the vintage engine (junit-vintage-engine 6.0.3 + junit 4.13.2)
Serenity 5.3 @RunWith(CucumberWithSerenity.class) runs Cucumber and builds the Serenity HTML report
Cucumber 7.34 Scenarios in src/test/resources/features, configured with @CucumberOptions(features = ..., glue = ...)
Playwright 1.60 Drives the browser; PlaywrightHooks opens one browser per scenario
BrowserStack SDK Runs every Playwright launch() on BrowserStack, names and marks each session, and sends each scenario to Test Reporting & Analytics

Prerequisites

  • Java 17 or newer
  • Maven 3.6.3 or newer
  • browserstack-java-sdk 1.77.0 or newer

Using Maven

Setup

  • Clone the repo
  • Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in browserstack.yml, or set the environment variables (see Notes)
  • Install dependencies mvn compile

Running your tests

  • To run a sample test, run mvn verify -P sample-test
  • To run local tests, run mvn verify -P sample-local-test

Each scenario runs once per platform in browserstack.yml. On BrowserStack you get:

  • Automate: one session per scenario, named <Feature> - <Scenario> and marked passed or failed with the reason.
  • Test Reporting & Analytics: one test per scenario, with steps, hooks and tags, linked to its session.

The Serenity report is written to target/site/serenity/index.html.

Integrate your test suite

Setting
browserstack.yml framework: cucumber-junit6 (not framework: serenity, which is for Serenity with Selenium)
Runner @RunWith(CucumberWithSerenity.class) + @CucumberOptions(features = ..., glue = ...)
JUnit junit:junit 4.13.2 and org.junit.vintage:junit-vintage-engine 6.x, because CucumberWithSerenity is a JUnit 4 runner
Cucumber io.cucumber:cucumber-junit
Browser Playwright; launch() and connect() both run on BrowserStack
SDK com.browserstack:browserstack-java-sdk 1.77.0+ with maven-dependency-plugin (goal properties) and the argLine -javaagent:${com.browserstack:browserstack-java-sdk:jar} on the plugin that runs the tests (see pom.xml)

Notes

  • Parallel runs: Cucumber's JUnit 4 runner runs the scenarios of a feature one after another. The JUnit vintage engine can run features in parallel (junit.vintage.execution.parallel.* in junit-platform.properties), not the scenarios inside one feature.

  • CucumberWithSerenity is deprecated for removal since Serenity 5.0.0, and JUnit 6 deprecates the vintage engine.

  • framework: cucumber-junit6 runs only through the BrowserStack CLI, which the SDK downloads at startup. If the CLI can't start, the run stops before any test and prints the reason.

  • You can view your test results on the BrowserStack Automate dashboard

  • You can export the environment variables for the Username and Access Key of your BrowserStack account

    export BROWSERSTACK_USERNAME=<browserstack-username> &&
    export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
    

About

Serenity BDD's Cucumber runner (CucumberWithSerenity) on JUnit 6 with Playwright, running on BrowserStack with the BrowserStack Java SDK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages