Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cfad198

Browse files
committedJan 4, 2022
Uploading project
1 parent 2c4da17 commit cfad198

38 files changed

+2048
-25
lines changed
 

‎.gitignore

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
5-
*.log
6-
7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.nar
17-
*.ear
18-
*.zip
19-
*.tar.gz
20-
*.rar
21-
22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
1+
target/
2+
build/
3+
.project
4+
.settings/
5+
.classpath
6+
.idea/
7+
.gradle/
8+
*.iml
9+
.DS_Store
10+
!gradle/wrapper/*

‎README.md

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,76 @@
1-
# browserstack-demo-testng
2-
BrowserStack demo across products using Java TestNG
1+
# BrowserStack Demo TestNG <a href="https://www.browserstack.com/"><img src="https://www.vectorlogo.zone/logos/browserstack/browserstack-icon.svg" alt="BrowserStack" height="30"/></a> <a href="https://java.com"><img src="https://www.vectorlogo.zone/logos/java/java-icon.svg" alt="Java" height="30" /></a> <a href="https://www.selenium.dev/"><img src="https://seeklogo.com/images/S/selenium-logo-DB9103D7CF-seeklogo.com.png" alt="Selenium" height="30" /></a>
2+
3+
| Product | Status |
4+
| --- | --- |
5+
| Automate | [![BrowserStack Status](https://automate.browserstack.com/badge.svg?badge_key=VVJsYk9IdWRoSG5TQldSbTE4elZZenlTS0V3S3hpWVRxTG9qWGdQVW5BVT0tLUFyV29QSTMwa1NiUkVmVWFIeUFoM2c9PQ==--36aaf62782c041f259b2e865d0364319ebc0947a)](https://automate.browserstack.com/public-build/VVJsYk9IdWRoSG5TQldSbTE4elZZenlTS0V3S3hpWVRxTG9qWGdQVW5BVT0tLUFyV29QSTMwa1NiUkVmVWFIeUFoM2c9PQ==--36aaf62782c041f259b2e865d0364319ebc0947a) |
6+
| App-Automate | [![BrowserStack Status](https://app-automate.browserstack.com/badge.svg?badge_key=czEwd3UxdlA0UkFuY0NpZ2h0eVI4V25qbTBwL1drbGg4My9rdUxneUdOYz0tLTJZT0NwVTlhVXVHbEROenhIamVFQlE9PQ==--e893df98cc09afe78a93a9b2ae4fb36a6495ac52)](https://app-automate.browserstack.com/public-build/czEwd3UxdlA0UkFuY0NpZ2h0eVI4V25qbTBwL1drbGg4My9rdUxneUdOYz0tLTJZT0NwVTlhVXVHbEROenhIamVFQlE9PQ==--e893df98cc09afe78a93a9b2ae4fb36a6495ac52) |
7+
8+
Test execution using [TestNG](http://testng.org) on BrowserStack.
9+
10+
## Using Maven
11+
12+
### Setup
13+
14+
- Clone the repo
15+
- Install dependencies `mvn compile`
16+
- Update the environment variables with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
17+
18+
### Running your tests
19+
20+
#### Automate
21+
22+
- To run a single test, run `mvn -P single test`
23+
- To run a local test, run `mvn -P local test`
24+
- To run parallel tests, run `mvn -P parallel test`
25+
- To run parallel tests on mobile browsers, run `mvn -P mobile test`
26+
- To run parallel local tests, run `mvn -P local-parallel test`
27+
- To run a failed test, run `mvn -P fail test`
28+
29+
#### App-Automate
30+
31+
- To run a single test, run `mvn -P appium-single test`
32+
- To run a local test, run `mvn -P appium-local test`
33+
- To run parallel tests, run `mvn -P appium-parallel test`
34+
- To run a failed test, run `mvn -P appium-fail test`
35+
- To run an Espresso test, run `mvn -P espresso test`
36+
- To run a XCUI test, run `mvn -P xcuitest test`
37+
38+
## Using Gradle
39+
40+
### Setup
41+
42+
* Clone the repo
43+
* Install dependencies `./gradlew build`
44+
* Update the environment variables with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
45+
46+
### Running your tests
47+
48+
#### Automate
49+
50+
- To run a single test, run `./gradlew single`
51+
- To run a local test, run `./gradlew local`
52+
- To run parallel tests, run `./gradlew parallel`
53+
- To run parallel tests on mobile browsers, run `./gradlew mobile`
54+
- To run parallel local tests, run `./gradlew local-parallel`
55+
- To run a failed test, run `./gradlew fail`
56+
57+
#### App-Automate
58+
59+
- To run a single test, run `./gradlew appium-single`
60+
- To run a local test, run `./gradlew appium-local`
61+
- To run parallel tests, run `./gradlew appium-parallel`
62+
- To run a failed test, run `./gradlew appium-fail`
63+
- To run an Espresso test, run `./gradlew espresso`
64+
- To run a XCUI test, run `./gradlew xcuitest`
65+
66+
## Notes
67+
- You can view your Automate test results on the [BrowserStack Automate dashboard](https://automate.browserstack.com/).
68+
- You can view your App-Automate test results on the [BrowserStack App-Automate dashboard](https://app-automate.browserstack.com/).
69+
- To start a locally hosted website, run `mvn -P start-server compile exec:java`. Website will open on `localhost:8000`.
70+
- To use specific number of threads:
71+
- For Maven use `-Dthreads=<thread-count>`. Example `-Dthreads=3`
72+
- For Gradle use `-Pthreads=<thread-count>`. Example `-Pthreads=3`
73+
- Export the environment variables for the Username and Access Key of your BrowserStack account.
74+
```sh
75+
export BROWSERSTACK_USERNAME=<browserstack-username> && export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
76+
```

‎build.gradle

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
group = 'com.browserstack'
2+
version = '1.0'
3+
description = 'browserstack-java-testng'
4+
5+
apply plugin: 'java'
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
sourceSets {
12+
test.java.srcDirs = ['src/test/java']
13+
test.resources.srcDirs = ['src/test/resources']
14+
}
15+
16+
dependencies {
17+
implementation 'io.appium:java-client:7.5.1'
18+
implementation 'org.testng:testng:7.4.0'
19+
implementation 'com.browserstack:browserstack-local-java:1.0.3'
20+
implementation 'io.rest-assured:rest-assured:4.3.3'
21+
}
22+
23+
tasks.register('single', Test) {
24+
useTestNG()
25+
include '**/SingleTest.class'
26+
testLogging {
27+
events "PASSED", "FAILED", "SKIPPED"
28+
}
29+
}
30+
31+
tasks.register('parallel', Test) {
32+
useTestNG() {
33+
suites 'src/test/resources/web/suites/parallel.testng.xml'
34+
parallel project.property('parallel')
35+
threadCount Integer.parseInt(project.property('threads'))
36+
}
37+
testLogging {
38+
events "PASSED", "FAILED", "SKIPPED"
39+
}
40+
}
41+
42+
tasks.register('fail', Test) {
43+
useTestNG()
44+
include '**/FailTest.class'
45+
testLogging {
46+
events "PASSED", "FAILED", "SKIPPED"
47+
}
48+
}
49+
50+
tasks.register('mobile', Test) {
51+
useTestNG() {
52+
suites 'src/test/resources/web/suites/mobile.testng.xml'
53+
parallel project.property('parallel')
54+
threadCount Integer.parseInt(project.property('threads'))
55+
}
56+
testLogging {
57+
events "PASSED", "FAILED", "SKIPPED"
58+
}
59+
}
60+
61+
tasks.register('local', Test) {
62+
useTestNG()
63+
include '**/LocalTest.class'
64+
testLogging {
65+
events "PASSED", "FAILED", "SKIPPED"
66+
}
67+
}
68+
69+
tasks.register('local-parallel', Test) {
70+
useTestNG() {
71+
suites 'src/test/resources/web/suites/local.testng.xml'
72+
parallel project.property('parallel')
73+
threadCount Integer.parseInt(project.property('threads'))
74+
}
75+
testLogging {
76+
events "PASSED", "FAILED", "SKIPPED"
77+
}
78+
}
79+
80+
tasks.register('appium-single', Test) {
81+
useTestNG()
82+
include '**/AppiumSingleTest.class'
83+
testLogging {
84+
events "PASSED", "FAILED", "SKIPPED"
85+
}
86+
}
87+
88+
tasks.register('appium-parallel', Test) {
89+
useTestNG() {
90+
suites 'src/test/resources/app/suites/parallel.testng.xml'
91+
parallel project.property('parallel')
92+
threadCount Integer.parseInt(project.property('threads'))
93+
}
94+
testLogging {
95+
events "PASSED", "FAILED", "SKIPPED"
96+
}
97+
}
98+
99+
tasks.register('appium-local', Test) {
100+
useTestNG()
101+
include '**/AppiumLocalTest.class'
102+
testLogging {
103+
events "PASSED", "FAILED", "SKIPPED"
104+
}
105+
}
106+
107+
tasks.register('appium-fail', Test) {
108+
useTestNG()
109+
include '**/AppiumFailTest.class'
110+
testLogging {
111+
events "PASSED", "FAILED", "SKIPPED"
112+
}
113+
}
114+
115+
tasks.register('espresso', Test) {
116+
useTestNG()
117+
include '**/EspressoTest.class'
118+
testLogging {
119+
events "PASSED", "FAILED", "SKIPPED"
120+
}
121+
}
122+
123+
tasks.register('xcuitest', Test) {
124+
useTestNG()
125+
include '**/XCUITest.class'
126+
testLogging {
127+
events "PASSED", "FAILED", "SKIPPED"
128+
}
129+
}

‎gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parallel=tests
2+
threads=5

‎gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)
Please sign in to comment.