|
1 | 1 | # Cucumber Java Browserstack |
2 | | -<img src="src/test/resources/img/browserstack.png" width="60" height="60" ><img src="src/test/resources/img/cucumber.png" width="60" height="60" > |
| 2 | + |
3 | 3 |
|
4 | 4 | [Cucumber JVM](https://cucumber.io/docs/reference/jvm) Integration with BrowserStack. |
5 | 5 |
|
|
8 | 8 | ### Run sample build |
9 | 9 |
|
10 | 10 | - Clone the repository |
| 11 | +- Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in browserstack.yml. |
11 | 12 | - Install dependencies `mvn compile` |
12 | 13 | - To run the test suite having cross-platform with parallelization, run `mvn test -P sample-test` |
13 | 14 | - To run local tests, run `mvn test -P sample-local-test` |
@@ -55,18 +56,43 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu |
55 | 56 | </plugin> |
56 | 57 | ``` |
57 | 58 |
|
58 | | -## Notes |
59 | | -* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) |
60 | | -* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/java#setting-os-and-browser) |
61 | | -* You can export the environment variables for the Username and Access Key of your BrowserStack account. |
| 59 | +### Migrate from Vanilla Cucumber to use Testng Runner |
| 60 | +* If you are using Vanilla Cucumber CLI, you can migrate to use TestNG Runner with BrowserStack using the below command : |
| 61 | +``` |
| 62 | +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 |
| 63 | +``` |
| 64 | +* Run your tests using `mvn test` |
| 65 | +* 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 |
62 | 66 |
|
| 67 | +## Using Gradle |
| 68 | + |
| 69 | +### Run sample build |
| 70 | + |
| 71 | +- Clone the repository |
| 72 | +- Install dependencies `gradle build` |
| 73 | +- To run the test suite having cross-platform with parallelization, run `gradle sampleTest` |
| 74 | +- To run local tests, run `gradle sampleLocalTest` |
| 75 | + |
| 76 | +Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) |
| 77 | + |
| 78 | +### Integrate your test suite |
| 79 | + |
| 80 | +* Install dependencies `gradle build` |
| 81 | +* Following are the changes required in `gradle.build` - |
| 82 | + * Add `compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies |
| 83 | + * Fetch Artifact Information and add `jvmArgs` property in tasks *SampleTest* and *SampleLocalTest* : |
63 | 84 | ``` |
64 | | - export BROWSERSTACK_USERNAME=<browserstack-username> && |
65 | | - export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key> |
| 85 | + def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } |
| 86 | + |
| 87 | + task sampleTest(type: Test) { |
| 88 | + useTestNG() { |
| 89 | + dependsOn cleanTest |
| 90 | + useDefaultListeners = true |
| 91 | + suites "config/sample-test.testng.xml" |
| 92 | + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" |
| 93 | + } |
| 94 | + } |
66 | 95 | ``` |
67 | 96 |
|
68 | | -## Addtional Resources |
69 | | -* [Documentation for writing Automate test scripts in Java](https://www.browserstack.com/automate/java) |
70 | | -* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities) |
71 | | -* [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate) |
72 | | -* [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api) |
| 97 | +## Notes |
| 98 | +* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) |
0 commit comments