Skip to content

updates project name #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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)
}
}
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -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:
Expand Down Expand Up @@ -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?

Expand All @@ -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:
Expand All @@ -265,21 +265,21 @@ 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:

- For \*nix based and Mac machines:

```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?
Expand All @@ -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
Expand All @@ -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:

Expand All @@ -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:
Expand Down Expand Up @@ -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?

Expand All @@ -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:
Expand All @@ -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?

Expand All @@ -416,27 +416,27 @@ 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:

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
Expand Down
26 changes: 26 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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"
}
}
46 changes: 45 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<dependency>
<groupId>com.browserstack</groupId>
<artifactId>browserstack-java-sdk</artifactId>
<version>1.1.1</version>
<version>1.3.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -211,6 +211,28 @@
</plugins>
</build>
</profile>
<profile>
<id>bstack-parallel-browsers</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-javaagent:${com.browserstack:browserstack-java-sdk:jar}
</argLine>
<systemPropertyVariables>
<browserstack-local>false</browserstack-local>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/conf/runners/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>percy</id>
<build>
Expand Down Expand Up @@ -305,5 +327,27 @@
</plugins>
</build>
</profile>
<profile>
<id>bstack-local-parallel-browsers</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-javaagent:${com.browserstack:browserstack-java-sdk:jar}
</argLine>
<systemPropertyVariables>
<browserstack-local>true</browserstack-local>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/conf/runners/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading