diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..a855aed
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,75 @@
+import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
+
+node {
+ try {
+ properties([
+ parameters([
+ credentials(credentialType: 'com.browserstack.automate.ci.jenkins.BrowserStackCredentials', defaultValue: '', description: 'Select your BrowserStack Username', name: 'BROWSERSTACK_USERNAME', required: true),
+ choice(
+ choices: [
+ 'bstack-single',
+ 'bstack-parallel',
+ 'bstack-parallel-browsers',
+ 'bstack-local',
+ 'bstack-local-parallel',
+ 'bstack-local-parallel-browsers'
+ ],
+ description: 'Select the test you would like to run',
+ name: 'TEST_TYPE'
+ )
+ ])
+ ])
+
+ stage('Pull code from Github') {
+ dir('test') {
+ git branch: 'main', changelog: false, poll: false, url: 'https://github.com/browserstack/browserstack-examples-testng'
+ }
+ }
+
+ stage('Run Test') {
+ browserstack(credentialsId: "${params.BROWSERSTACK_USERNAME}") {
+ def user = "${env.BROWSERSTACK_USERNAME}"
+ if (user.contains('-')) {
+ user = user.substring(0, user.lastIndexOf('-'))
+ }
+ withEnv(['BROWSERSTACK_USERNAME=' + user]) {
+ sh label: '', returnStatus: true, script:'''#!/bin/bash -l
+ cd test
+ ln src/test/resources/conf/capabilities/${TEST_TYPE}.yml browserstack.yml
+ mvn clean test -P ${TEST_TYPE} '''
+ }
+ }
+ }
+
+ stage('Generate Report') {
+ browserStackReportPublisher 'automate'
+ }
+ }catch (e) {
+ currentBuild.result = 'FAILURE'
+ echo e
+ throw e
+ } finally {
+ notifySlack(currentBuild.result)
+ }
+}
+def notifySlack(String buildStatus = 'STARTED') {
+ // Build status of null means success.
+ buildStatus = buildStatus ?: 'SUCCESS'
+
+ def color
+
+ if (buildStatus == 'STARTED') {
+ color = '#D4DADF'
+ } else if (buildStatus == 'SUCCESS') {
+ color = '#BDFFC3'
+ } else if (buildStatus == 'UNSTABLE') {
+ color = '#FFFE89'
+ } else {
+ color = '#FF9FA1'
+ }
+
+ def msg = "${buildStatus}: `${env.JOB_NAME}` #${env.BUILD_NUMBER}:\n${env.BUILD_URL}"
+ if (buildStatus != 'STARTED' && buildStatus != 'SUCCESS') {
+ slackSend(color: color, message: msg)
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index f8a9402..25a3858 100644
--- a/README.md
+++ b/README.md
@@ -171,7 +171,7 @@ Note:
### Run a specific test on BrowserStack
-In this section, we will run a single test on Chrome browser on Browserstack. To change test capabilities for this configuration, please refer to the `browserstack-single.yml` file.
+In this section, we will run a single test on Chrome browser on Browserstack. To change test capabilities for this configuration, please refer to the `bstack-single.yml` file.
- How to run the test?
@@ -181,13 +181,13 @@ In this section, we will run a single test on Chrome browser on Browserstack. To
```sh
rm -f -- browserstack.yml
- ln src/test/resources/conf/capabilities/browserstack-single.yml browserstack.yml
+ ln src/test/resources/conf/capabilities/bstack-single.yml browserstack.yml
```
- For Windows:
```sh
- del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\browserstack-single.yml browserstack.yml
+ del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\bstack-single.yml browserstack.yml
```
To run the default test scenario (e.g. End to End Scenario) on your own machine, use the following command:
@@ -226,7 +226,7 @@ In this section, we will run a single test on Chrome browser on Browserstack. To
### Run the entire test suite in parallel on a single BrowserStack browser
-In this section, we will run the tests in parallel on a single browser on Browserstack. Refer to `browserstack-parallel.yml` file to change test capabilities for this configuration.
+In this section, we will run the tests in parallel on a single browser on Browserstack. Refer to `bstack-parallel.yml` file to change test capabilities for this configuration.
- How to run the test?
@@ -236,13 +236,13 @@ In this section, we will run the tests in parallel on a single browser on Browse
```sh
rm -f -- browserstack.yml
- ln src/test/resources/conf/capabilities/browserstack-parallel.yml browserstack.yml
+ ln src/test/resources/conf/capabilities/bstack-parallel.yml browserstack.yml
```
- For Windows:
```sh
- del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\browserstack-parallel.yml browserstack.yml
+ del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\bstack-parallel.yml browserstack.yml
```
To run the entire test suite in parallel on a single BrowserStack browser, use the following command:
@@ -265,7 +265,7 @@ In this section, we will run the tests in parallel on a single browser on Browse
### Run the entire test suite in parallel on multiple BrowserStack browsers
-In this section, we will run the tests in parallel on multiple browsers on Browserstack. Refer to the `browserstack-parallel-browsers.yml` file to change test capabilities for this configuration.
+In this section, we will run the tests in parallel on multiple browsers on Browserstack. Refer to the `bstack-parallel-browsers.yml` file to change test capabilities for this configuration.
- Copy the capabilities to the root of the project:
@@ -273,13 +273,13 @@ In this section, we will run the tests in parallel on multiple browsers on Brows
```sh
rm -f -- browserstack.yml
- ln src/test/resources/conf/capabilities/browserstack-parallel-browsers.yml browserstack.yml
+ ln src/test/resources/conf/capabilities/bstack-parallel-browsers.yml browserstack.yml
```
- For Windows:
```sh
- del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\browserstack-parallel-browsers.yml browserstack.yml
+ del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\bstack-parallel-browsers.yml browserstack.yml
```
- How to run the test?
@@ -289,13 +289,13 @@ In this section, we will run the tests in parallel on multiple browsers on Brows
Maven:
```sh
- mvn clean test -P bstack-parallel
+ mvn clean test -P bstack-parallel-browsers
```
Gradle:
```sh
- gradle clean bstack-parallel
+ gradle clean bstack-parallel-browsers
```
### [Web application hosted on internal environment] Running your tests on BrowserStack using BrowserStackLocal
@@ -307,7 +307,7 @@ In this section, we will run the tests in parallel on multiple browsers on Brows
git clone https://github.com/browserstack/browserstack-demo-app
```
- Please follow the README.md on the BrowserStack demo application repository to install and start the dev server on localhost.
-- In this section, we will run a single test case to test the BrowserStack Demo app hosted on your local machine i.e. localhost. Refer to the `browserstack-local.yml` file to change test capabilities for this configuration.
+- In this section, we will run a single test case to test the BrowserStack Demo app hosted on your local machine i.e. localhost. Refer to the `bstack-local.yml` file to change test capabilities for this configuration.
- Note: You may need to provide additional BrowserStackLocal arguments to successfully connect your localhost environment with BrowserStack infrastructure. (e.g if you are behind firewalls, proxy or VPN).
- Further details for successfully creating a BrowserStackLocal connection can be found here:
@@ -324,13 +324,13 @@ In this section, we will run the tests in parallel on multiple browsers on Brows
```sh
rm -f -- browserstack.yml
- ln src/test/resources/conf/capabilities/browserstack-local.yml browserstack.yml
+ ln src/test/resources/conf/capabilities/bstack-local.yml browserstack.yml
```
- For Windows:
```sh
- del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\browserstack-local.yml browserstack.yml
+ del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\bstack-local.yml browserstack.yml
```
- To run the default test scenario (e.g. End to End Scenario) on a single BrowserStack browser using BrowserStackLocal, use the following command:
@@ -368,7 +368,7 @@ In this section, we will run the tests in parallel on multiple browsers on Brows
### [Web application hosted on internal environment] Run the entire test suite in parallel on a single BrowserStack browser using BrowserStackLocal
-In this section, we will run the test cases to test the internally hosted website in parallel on a single browser on Browserstack. Refer to the `browserstack-local-parallel.yml` file to change test capabilities for this configuration.
+In this section, we will run the test cases to test the internally hosted website in parallel on a single browser on Browserstack. Refer to the `bstack-local-parallel.yml` file to change test capabilities for this configuration.
- How to run the test?
@@ -378,13 +378,13 @@ In this section, we will run the test cases to test the internally hosted websit
```sh
rm -f -- browserstack.yml
- ln src/test/resources/conf/capabilities/browserstack-local-parallel.yml browserstack.yml
+ ln src/test/resources/conf/capabilities/bstack-local-parallel.yml browserstack.yml
```
- For Windows:
```sh
- del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\browserstack-local-parallel.yml browserstack.yml
+ del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\bstack-local-parallel.yml browserstack.yml
```
To run the entire test suite in parallel on a single BrowserStack browser using BrowserStackLocal, use the following command:
@@ -406,7 +406,7 @@ In this section, we will run the test cases to test the internally hosted websit
### [Web application hosted on internal environment] Run the entire test suite in parallel on multiple BrowserStack browser using BrowserStackLocal
-In this section, we will run the test cases to test the internally hosted website in parallel on multiple browsers on Browserstack. Refer to the `browserstack-local-parallel-browsers.yml` file to change test capabilities for this configuration.
+In this section, we will run the test cases to test the internally hosted website in parallel on multiple browsers on Browserstack. Refer to the `bstack-local-parallel-browsers.yml` file to change test capabilities for this configuration.
- How to run the test?
@@ -416,13 +416,13 @@ In this section, we will run the test cases to test the internally hosted websit
```sh
rm -f -- browserstack.yml
- ln src/test/resources/conf/capabilities/browserstack-local-parallel-browsers.yml browserstack.yml
+ ln src/test/resources/conf/capabilities/bstack-local-parallel-browsers.yml browserstack.yml
```
- For Windows:
```sh
- del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\browserstack-local-parallel-browsers.yml browserstack.yml
+ del /f "browserstack.yml" && copy /y .\src\test\resources\conf\capabilities\bstack-local-parallel-browsers.yml browserstack.yml
```
To run the entire test suite in parallel on a single BrowserStack browser using BrowserStackLocal, use the following command:
@@ -430,13 +430,13 @@ In this section, we will run the test cases to test the internally hosted websit
Maven:
```sh
- mvn clean test -P bstack-local-parallel
+ mvn clean test -P bstack-local-parallel-browsers
```
Gradle:
```sh
- gradle clean bstack-local-parallel
+ gradle clean bstack-local-parallel-browsers
```
- Output
diff --git a/build.gradle b/build.gradle
index ef96f61..466285f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -94,6 +94,19 @@ tasks.register('bstack-parallel', Test) {
}
}
+tasks.register('bstack-parallel-browsers', Test) {
+ useTestNG() {
+ dependsOn clean
+ useDefaultListeners = true
+ suites 'src/test/resources/conf/runners/testng.xml'
+ jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
+ }
+ systemProperty "browserstack-local", "false"
+ systemProperty "testType", "parallel"
+ testLogging {
+ events "PASSED", "FAILED", "SKIPPED"
+ }
+}
tasks.register('percy', Test) {
useTestNG() {
@@ -148,3 +161,16 @@ tasks.register('bstack-local-parallel', Test) {
events "PASSED", "FAILED", "SKIPPED"
}
}
+
+tasks.register('bstack-local-parallel-browsers', Test) {
+ useTestNG() {
+ dependsOn clean
+ useDefaultListeners = true
+ suites 'src/test/resources/conf/runners/testng.xml'
+ jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
+ }
+ systemProperty "browserstack-local", "true"
+ testLogging {
+ events "PASSED", "FAILED", "SKIPPED"
+ }
+}
diff --git a/pom.xml b/pom.xml
index d5435cf..55281d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,7 @@
com.browserstack
browserstack-java-sdk
- 1.1.1
+ 1.3.0
compile
@@ -211,6 +211,28 @@
+
+ bstack-parallel-browsers
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+ false
+
+
+ src/test/resources/conf/runners/testng.xml
+
+
+
+
+
+
percy
@@ -305,5 +327,27 @@
+
+ bstack-local-parallel-browsers
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+ true
+
+
+ src/test/resources/conf/runners/testng.xml
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/conf/capabilities/browserstack-local-parallel-browsers.yml b/src/test/resources/conf/capabilities/bstack-local-parallel-browsers.yml
similarity index 98%
rename from src/test/resources/conf/capabilities/browserstack-local-parallel-browsers.yml
rename to src/test/resources/conf/capabilities/bstack-local-parallel-browsers.yml
index 1135878..c59feb2 100644
--- a/src/test/resources/conf/capabilities/browserstack-local-parallel-browsers.yml
+++ b/src/test/resources/conf/capabilities/bstack-local-parallel-browsers.yml
@@ -18,7 +18,7 @@ accessKey: BROWSERSTACK_ACCESS_KEY
# executions will be grouped together on BrowserStack
buildName: browserstack-build-1
# Use `projectName` to set the name of your project. Example, Marketing Website
-projectName: BrowserStack Samples
+projectName: BrowserStack Examples TestNG
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
framework: testng
diff --git a/src/test/resources/conf/capabilities/browserstack-local-parallel.yml b/src/test/resources/conf/capabilities/bstack-local-parallel.yml
similarity index 98%
rename from src/test/resources/conf/capabilities/browserstack-local-parallel.yml
rename to src/test/resources/conf/capabilities/bstack-local-parallel.yml
index 145382d..b64ffe3 100644
--- a/src/test/resources/conf/capabilities/browserstack-local-parallel.yml
+++ b/src/test/resources/conf/capabilities/bstack-local-parallel.yml
@@ -18,7 +18,7 @@ accessKey: BROWSERSTACK_ACCESS_KEY
# executions will be grouped together on BrowserStack
buildName: browserstack-build-1
# Use `projectName` to set the name of your project. Example, Marketing Website
-projectName: BrowserStack Samples
+projectName: BrowserStack Examples TestNG
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
framework: testng
diff --git a/src/test/resources/conf/capabilities/browserstack-local.yml b/src/test/resources/conf/capabilities/bstack-local.yml
similarity index 98%
rename from src/test/resources/conf/capabilities/browserstack-local.yml
rename to src/test/resources/conf/capabilities/bstack-local.yml
index afe2bb5..d58f2bc 100644
--- a/src/test/resources/conf/capabilities/browserstack-local.yml
+++ b/src/test/resources/conf/capabilities/bstack-local.yml
@@ -18,7 +18,7 @@ accessKey: BROWSERSTACK_ACCESS_KEY
# executions will be grouped together on BrowserStack
buildName: browserstack-build-1
# Use `projectName` to set the name of your project. Example, Marketing Website
-projectName: BrowserStack Samples
+projectName: BrowserStack Examples TestNG
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
framework: testng
diff --git a/src/test/resources/conf/capabilities/browserstack-parallel-browsers.yml b/src/test/resources/conf/capabilities/bstack-parallel-browsers.yml
similarity index 98%
rename from src/test/resources/conf/capabilities/browserstack-parallel-browsers.yml
rename to src/test/resources/conf/capabilities/bstack-parallel-browsers.yml
index da1e081..99c8fc1 100644
--- a/src/test/resources/conf/capabilities/browserstack-parallel-browsers.yml
+++ b/src/test/resources/conf/capabilities/bstack-parallel-browsers.yml
@@ -18,7 +18,7 @@ accessKey: BROWSERSTACK_ACCESS_KEY
# executions will be grouped together on BrowserStack
buildName: browserstack-build-1
# Use `projectName` to set the name of your project. Example, Marketing Website
-projectName: BrowserStack Samples
+projectName: BrowserStack Examples TestNG
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
framework: testng
diff --git a/src/test/resources/conf/capabilities/browserstack-parallel.yml b/src/test/resources/conf/capabilities/bstack-parallel.yml
similarity index 98%
rename from src/test/resources/conf/capabilities/browserstack-parallel.yml
rename to src/test/resources/conf/capabilities/bstack-parallel.yml
index bfc8dd6..49c449c 100644
--- a/src/test/resources/conf/capabilities/browserstack-parallel.yml
+++ b/src/test/resources/conf/capabilities/bstack-parallel.yml
@@ -18,7 +18,7 @@ accessKey: BROWSERSTACK_ACCESS_KEY
# executions will be grouped together on BrowserStack
buildName: browserstack-build-1
# Use `projectName` to set the name of your project. Example, Marketing Website
-projectName: BrowserStack Samples
+projectName: BrowserStack Examples TestNG
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
framework: testng
diff --git a/src/test/resources/conf/capabilities/browserstack-single.yml b/src/test/resources/conf/capabilities/bstack-single.yml
similarity index 98%
rename from src/test/resources/conf/capabilities/browserstack-single.yml
rename to src/test/resources/conf/capabilities/bstack-single.yml
index 9bb289e..3ea1a07 100644
--- a/src/test/resources/conf/capabilities/browserstack-single.yml
+++ b/src/test/resources/conf/capabilities/bstack-single.yml
@@ -18,7 +18,7 @@ accessKey: BROWSERSTACK_ACCESS_KEY
# executions will be grouped together on BrowserStack
buildName: browserstack-build-1
# Use `projectName` to set the name of your project. Example, Marketing Website
-projectName: BrowserStack Samples
+projectName: BrowserStack Examples TestNG
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
framework: testng