https://github.com/browserstack/cucumber-java-browserstack
https://github.com/browserstack/cucumber-java-browserstack
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/browserstack/cucumber-java-browserstack
- Owner: browserstack
- Created: 2017-01-09T09:05:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-29T05:37:50.000Z (about 1 year ago)
- Last Synced: 2025-04-22T21:06:10.401Z (11 months ago)
- Language: Java
- Size: 126 KB
- Stars: 7
- Watchers: 23
- Forks: 24
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Cucumber Java Browserstack
| [Cucumber-TestNG](https://github.com/browserstack/cucumber-java-browserstack/tree/master) | [Cucumber-JUnit4](https://github.com/browserstack/cucumber-java-browserstack/tree/cucumber-junit4) | [Cucumber-JUnit5](https://github.com/browserstack/cucumber-java-browserstack/tree/cucumber-junit5) |
| ------------------------------------------------------ | ------------------------------------------------- | ------------------------------------------------- |

[Cucumber JVM](https://cucumber.io/docs/reference/jvm) Integration with BrowserStack.
## Using Maven
### Run sample build
- Clone the repository
- Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in 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 view Allure Reports, run `allure serve target/allure-results`
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
* 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
```sh
com.browserstack
browserstack-java-sdk
LATEST
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 :
```
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
```
* 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
- Clone the repository
- Install dependencies `gradle build`
- To run the test suite having cross-platform with parallelization, run `gradle sampleTest`
- To run local tests, run `gradle sampleLocalTest`
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
* Install dependencies `gradle build`
* Following are the changes required in `gradle.build` -
* Add `compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies
* Fetch Artifact Information and add `jvmArgs` property in tasks *SampleTest* and *SampleLocalTest* :
```
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
task sampleTest(type: Test) {
useTestNG() {
dependsOn cleanTest
useDefaultListeners = true
suites "config/sample-test.testng.xml"
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
}
}
```
## Notes
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)