diff --git a/README.md b/README.md index 27d7147..9c7155d 100644 --- a/README.md +++ b/README.md @@ -3,23 +3,30 @@ [Cucumber JVM](https://cucumber.io/docs/reference/jvm) Integration with BrowserStack. -## Using Maven +### Using Maven -### Run sample build +## Run sample build - Clone the repository -- Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in browserstack.yml. +- Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in [browserstack.yml](https://github.com/browserstack/cucumber-java-browserstack/blob/sdk/browserstack.yml). - Install dependencies `mvn compile` -- To run the test suite having cross-platform with parallelization, run `mvn test -P sample-test` -- To run local tests, run `mvn test -P sample-local-test` +- To run a sample test suite run `mvn test -P sample-test` +- To enable BrowserStack Local, set `browserstackLocal: true` in your `browserstack.yml` file and check its status by running `mvn test -P sample-local-test` -Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) -### Integrate your test suite +## Integrate your test suite using BrowserStack SDK +You can run your existing test suite on BrowserStack's selenium cloud using the BrowserStack SDK. It provides a plug-and-play integration with Cucumber-JVM. Our SDK is compatible with Cucumber-JVM using the TestNG runner. + +### Add Testng Runner to your Cucumber project (if not added) +If you are using the Cucumber CLI runner, you can migrate to the TestNG Runner out of the box using the below command: +``` +mvn archetype:generate -DarchetypeGroupId=com.browserstack -DarchetypeArtifactId=cucumber-testng-archetype -DarchetypeVersion=1.0 -DgroupId=com.browserstack -DartifactId=cucumber-testng-archetype -Dversion=1.0 -DinteractiveMode=false +``` +* To use specific `@CucumberOptions` in generated class `BrowserStackCucumberTestNgRunner`, refer - https://javadoc.io/static/io.cucumber/cucumber-testng/5.0.0-RC2/io/cucumber/testng/CucumberOptions.html + +### Install SDK -* Install dependencies `mvn compile` -* Create sample browserstack.yml file with the browserstack related capabilities with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings) and place it in your root folder. -* Add maven dependency of browserstack-java-sdk in your pom.xml file +Add maven dependency of browserstack-java-sdk in your pom.xml file ```sh com.browserstack @@ -28,45 +35,52 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu compile ``` -* Modify your build plugin to run tests by adding argLine `-javaagent:${com.browserstack:browserstack-java-sdk:jar}` and `maven-dependency-plugin` for resolving dependencies in the profiles `sample-test` and `sample-local-test`. -``` - - maven-dependency-plugin - - - getClasspathFilenames - - properties - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M5 - - - src/test/resources/testng.xml - - - -javaagent:${com.browserstack:browserstack-java-sdk:jar} - - - -``` -### Migrate from Vanilla Cucumber to use Testng Runner -* If you are using Vanilla Cucumber CLI, you can migrate to use TestNG Runner with BrowserStack using the below command : +Modify your build plugin to run tests by adding argLine `-javaagent:${com.browserstack:browserstack-java-sdk:jar}` and `maven-dependency-plugin` for resolving dependencies in the profiles `sample-test` and `sample-local-test`. ``` -mvn archetype:generate -DarchetypeGroupId=com.browserstack -DarchetypeArtifactId=cucumber-testng-archetype -DarchetypeVersion=1.0 -DgroupId=com.browserstack -DartifactId=cucumber-testng-archetype -Dversion=1.0 -DinteractiveMode=false + + maven-dependency-plugin + + + getClasspathFilenames + + properties + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + src/test/resources/testng.xml + + + -javaagent:${com.browserstack:browserstack-java-sdk:jar} + + + ``` -* Run your tests using `mvn test` -* To use specific `@CucumberOptions` in generated class `BrowserStackCucumberTestNgRunner`, refer - https://javadoc.io/static/io.cucumber/cucumber-testng/5.0.0-RC2/io/cucumber/testng/CucumberOptions.html -## Using Gradle -### Run sample build + +Install dependencies using `mvn compile` + +### Download browserstack.yml file + +[Download sample browserstack.yml](https://github.com/browserstack/cucumber-java-browserstack/blob/sdk/browserstack.yml) file and and place it in your root folder. Ensure set your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings) in the config file. + + +### Run your test suite +Run your test suite using your `mvn` build command. The tests should start running on BrowserStack on the platform combinations (OS,Browser/Device) set in the `browserstack.yml` config file. + +--- + +### Using Gradle + +## Run sample build - Clone the repository - Install dependencies `gradle build` @@ -75,7 +89,7 @@ mvn archetype:generate -DarchetypeGroupId=com.browserstack -DarchetypeArtifactId Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) -### Integrate your test suite +## Integrate your test suite * Install dependencies `gradle build` * Following are the changes required in `gradle.build` - @@ -96,3 +110,4 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu ## Notes * You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) +* Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)