Skip to content

Commit bc48d27

Browse files
Merge pull request #19 from browserstack/update-sdk-readme
Update sdk readme
2 parents 350dce0 + f09291c commit bc48d27

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ logs/
1919

2020
local.log
2121
reports
22+
.gradle
23+
gradle
24+
build

README.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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+
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
33

44
[Cucumber JVM](https://cucumber.io/docs/reference/jvm) Integration with BrowserStack.
55

@@ -8,6 +8,7 @@
88
### Run sample build
99

1010
- Clone the repository
11+
- Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in browserstack.yml.
1112
- Install dependencies `mvn compile`
1213
- To run the test suite having cross-platform with parallelization, run `mvn test -P sample-test`
1314
- 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
5556
</plugin>
5657
```
5758

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
6266

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* :
6384
```
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+
}
6695
```
6796

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

Comments
 (0)