https://github.com/browserstack/testng-browserstack
Selenium examples for TestNG and BrowserStack Automate
https://github.com/browserstack/testng-browserstack
Last synced: 12 months ago
JSON representation
Selenium examples for TestNG and BrowserStack Automate
- Host: GitHub
- URL: https://github.com/browserstack/testng-browserstack
- Owner: browserstack
- Created: 2016-03-01T08:34:12.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-09-05T10:17:44.000Z (over 1 year ago)
- Last Synced: 2025-03-31T07:05:18.561Z (12 months ago)
- Language: Java
- Homepage: https://www.browserstack.com
- Size: 27.4 MB
- Stars: 73
- Watchers: 21
- Forks: 150
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# testng-browserstack
[TestNG](http://testng.org) 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`
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
This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack:
* 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
config/sample-local-test.testng.xml
-javaagent:${com.browserstack:browserstack-java-sdk:jar}
```
* Install dependencies `mvn compile`
## Using Gradle
### Prerequisites
- If using Gradle, Java v9+ is required.
### 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
This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack:
* 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}"
}
}
```
* Install dependencies `gradle build`
## Notes
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)