Skip to content

Commit a68795f

Browse files
kamal-kaur04francisf
authored andcommitted
add: sdk samples for JUnit 4, 5
1 parent b1836e0 commit a68795f

File tree

12 files changed

+208
-365
lines changed

12 files changed

+208
-365
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ target/
33
local.log
44
.idea
55
*.iml
6-
android/junit4-examples/logs
6+
*/*/logs

README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,22 @@ Getting Started with Appium tests in Junit4 and Junit5 on BrowserStack couldn't
6868
### **Run first test :**
6969
7070
- Junit4
71-
- Update `first.conf.json` file inside the `src/test/resources/com/browserstack/run_first_test` of Android Junit4 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
72-
- Run `mvn test -P first`
71+
- Update `browserstack.yml` file at root level of Android Junit4 examples or iOS Junit4 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
72+
- Run `mvn test -P sample-test`
7373
7474
- Junit5
75-
- Update `first.conf.json` file inside the `src/test/resources/com/browserstack/run_first_test` of Android Junit5 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
76-
- Run `mvn test -P first`
77-
78-
### **Speed up test execution with parallel testing :**
79-
80-
- Junit4
81-
- Update `parallel.conf.json` file inside the `src/test/resources/com/browserstack/run_parallel_test` of Android Junit4 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
82-
- Run `mvn test -P parallel`
83-
84-
- Junit5
85-
- Update `parallel.conf.json` file inside the `src/test/resources/com/browserstack/run_parallel_test` of Android Junit5 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
86-
- Run `mvn test -P parallel`
75+
- Update `browserstack.yml` file at root level of Android Junit5 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
76+
- Run `mvn test -P sample-test`
8777
8878
### **Use Local testing for apps that access resources hosted in development or testing environments :**
8979
9080
- Junit4
91-
- Update `local.conf.json` file inside the `src/test/resources/com/browserstack/run_local_test` of Android Junit4 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
92-
- Run `mvn test -P local`
81+
- Update `browserstack.yml` file at root level of Android Junit4 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
82+
- Run `mvn test -P sample-local-test`
9383
9484
- Junit5
95-
- Update `local.conf.json` file inside the `src/test/resources/com/browserstack/run_local_test` of Android Junit5 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
96-
- Run `mvn test -P local`
85+
- Update `browserstack.yml` file at root level of Android Junit5 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
86+
- Run `mvn test -P sample-local-test`
9787
9888
**Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help)
9989

android/junit4-examples/browserstack.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
# =============================
22
# Set BrowserStack Credentials
33
# =============================
4-
# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and
4+
# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and
55
# BROWSERSTACK_ACCESS_KEY as env variables
6-
userName: YOUR_USERNAME
7-
accessKey: YOUR_ACCESS_KEY
6+
userName: BROWSERSTACK_USERNAME
7+
accessKey: BROWSERSTACK_ACCESS_KEY
88

99
# ======================
10-
# Organizing your tests
10+
# BrowserStack Reporting
1111
# ======================
12-
# Use `projectName`, `buildName`, `name` capabilities to organize your tests
13-
# `name` is the name of your test sessions and is automatically picked from your
14-
# test name and doesn't need to be set manually when using BrowserStack SDK
15-
# `buildName` is used to name your CI/CD job or the execution of your test suite.
16-
# Ensure you add a dynamic identifier, like an incremental build number from your
17-
# CI/CD or timestamp at the end of every build; otherwise tests from different
18-
# executions will be grouped together on BrowserStack
19-
buildName: browserstack-build
20-
# Use `projectName` to set the name of your project. Example, Marketing Website
12+
# The following capabilities are used to set up reporting on BrowserStack:
13+
# Set 'projectName' to the name of your project. Example, Marketing Website
2114
projectName: BrowserStack Samples
22-
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
15+
# Set `buildName` as the name of the job / testsuite being run
16+
buildName: browserstack build
17+
# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
18+
# buildName. Choose your buildIdentifier format from the available expressions:
19+
# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
20+
# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
21+
# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
22+
buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
23+
# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
24+
# This property is needed to send test context to BrowserStack (test name, status)
2325
framework: junit4
2426

25-
source: junit:sample-sdk:v1.0
27+
source: junit4:appium-sample-sdk:v1.0
2628

2729
app: ../WikipediaSample.apk
30+
#app: ../LocalSample.apk #For running local tests
2831

2932
# =======================================
3033
# Platforms (Browsers / Devices to test)

android/junit4-examples/pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<surefire.version>3.0.0-M5</surefire.version>
1616

17-
<config.file>default</config.file>
17+
<config.file>FirstTest.java</config.file>
1818
</properties>
1919

2020
<dependencies>
@@ -70,9 +70,16 @@
7070
<groupId>org.apache.maven.plugins</groupId>
7171
<artifactId>maven-surefire-plugin</artifactId>
7272
<version>${surefire.version}</version>
73+
<dependencies>
74+
<dependency>
75+
<groupId>org.apache.maven.surefire</groupId>
76+
<artifactId>surefire-junit47</artifactId>
77+
<version>${surefire.version}</version>
78+
</dependency>
79+
</dependencies>
7380
<configuration>
7481
<includes>
75-
<include>com/browserstack/FirstTest.java</include>
82+
<include>${config.file}</include>
7683
</includes>
7784
<argLine>-javaagent:${com.browserstack:browserstack-java-sdk:jar}</argLine>
7885
</configuration>

ios/junit4-examples/browserstack.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ buildName: browserstack build
2222
buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
2323
# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
2424
# This property is needed to send test context to BrowserStack (test name, status)
25-
framework: junit5
25+
framework: junit4
2626

27-
source: junit5:appium-sample-sdk:v1.0
27+
source: junit4:appium-sample-sdk:v1.0
2828

2929
app: ../BStackSampleApp.ipa
3030
#app: ../LocalSample.ipa #For running local tests
@@ -55,7 +55,7 @@ platforms:
5555
# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
5656
#
5757
# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
58-
parallelsPerPlatform: 2
58+
parallelsPerPlatform: 1
5959

6060
# ==========================================
6161
# BrowserStack Local

ios/junit4-examples/pom.xml

Lines changed: 59 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>com.browserstack</groupId>
@@ -12,51 +12,70 @@
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<surefire.version>2.19.1</surefire.version>
15+
<surefire.version>3.0.0-M5</surefire.version>
1616

17-
<test.file></test.file>
1817
<config.file>default</config.file>
1918
</properties>
2019

2120
<dependencies>
22-
<dependency>
23-
<groupId>junit</groupId>
24-
<artifactId>junit</artifactId>
25-
<version>4.13.2</version>
26-
</dependency>
27-
<dependency>
28-
<groupId>commons-io</groupId>
29-
<artifactId>commons-io</artifactId>
30-
<version>2.11.0</version>
31-
</dependency>
32-
<dependency>
33-
<groupId>org.seleniumhq.selenium</groupId>
34-
<artifactId>selenium-java</artifactId>
35-
<version>4.4.0</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>io.appium</groupId>
39-
<artifactId>java-client</artifactId>
40-
<version>8.1.1</version>
41-
</dependency>
42-
<dependency>
43-
<groupId>com.browserstack</groupId>
44-
<artifactId>browserstack-local-java</artifactId>
45-
<version>1.0.3</version>
46-
</dependency>
47-
<dependency>
48-
<groupId>com.googlecode.json-simple</groupId>
49-
<artifactId>json-simple</artifactId>
50-
<version>1.1.1</version>
51-
</dependency>
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<version>4.13.2</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>commons-io</groupId>
28+
<artifactId>commons-io</artifactId>
29+
<version>2.11.0</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.seleniumhq.selenium</groupId>
33+
<artifactId>selenium-java</artifactId>
34+
<version>4.4.0</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.appium</groupId>
38+
<artifactId>java-client</artifactId>
39+
<version>8.1.1</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.googlecode.json-simple</groupId>
43+
<artifactId>json-simple</artifactId>
44+
<version>1.1.1</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>com.browserstack</groupId>
48+
<artifactId>browserstack-java-sdk</artifactId>
49+
<version>LATEST</version>
50+
<scope>compile</scope>
51+
</dependency>
5252
</dependencies>
5353

5454
<build>
5555
<plugins>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-dependency-plugin</artifactId>
59+
<version>3.3.0</version>
60+
<executions>
61+
<execution>
62+
<id>getClasspathFilenames</id>
63+
<goals>
64+
<goal>properties</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
</plugin>
5669
<plugin>
5770
<groupId>org.apache.maven.plugins</groupId>
5871
<artifactId>maven-surefire-plugin</artifactId>
59-
<version>2.22.2</version>
72+
<version>${surefire.version}</version>
73+
<configuration>
74+
<includes>
75+
<include>com/browserstack/FirstTest.java</include>
76+
</includes>
77+
<argLine>-javaagent:${com.browserstack:browserstack-java-sdk:jar}</argLine>
78+
</configuration>
6079
</plugin>
6180
<plugin>
6281
<groupId>org.apache.maven.plugins</groupId>
@@ -72,61 +91,37 @@
7291

7392
<profiles>
7493
<profile>
75-
<id>first</id>
94+
<id>sample-test</id>
7695
<build>
7796
<plugins>
7897
<plugin>
7998
<groupId>org.apache.maven.plugins</groupId>
8099
<artifactId>maven-surefire-plugin</artifactId>
100+
<version>${surefire.version}</version>
81101
<configuration>
82102
<includes>
83103
<include>com/browserstack/FirstTest.java</include>
84104
</includes>
85-
<systemPropertyVariables>
86-
<config>run_first_test/first.conf.json</config>
87-
</systemPropertyVariables>
105+
<argLine>-javaagent:${com.browserstack:browserstack-java-sdk:jar}</argLine>
88106
</configuration>
89107
</plugin>
90108
</plugins>
91109
</build>
92110
</profile>
93111

94112
<profile>
95-
<id>local</id>
113+
<id>sample-local-test</id>
96114
<build>
97115
<plugins>
98116
<plugin>
99117
<groupId>org.apache.maven.plugins</groupId>
100118
<artifactId>maven-surefire-plugin</artifactId>
119+
<version>${surefire.version}</version>
101120
<configuration>
102121
<includes>
103122
<include>com/browserstack/LocalTest.java</include>
104123
</includes>
105-
<systemPropertyVariables>
106-
<config>run_local_test/local.conf.json</config>
107-
</systemPropertyVariables>
108-
</configuration>
109-
</plugin>
110-
</plugins>
111-
</build>
112-
</profile>
113-
114-
<profile>
115-
<id>parallel</id>
116-
<build>
117-
<plugins>
118-
<plugin>
119-
<groupId>org.apache.maven.plugins</groupId>
120-
<artifactId>maven-surefire-plugin</artifactId>
121-
<configuration>
122-
<parallel>classes</parallel>
123-
<threadCount>2</threadCount>
124-
<includes>
125-
<include>com/browserstack/FirstTest.java</include>
126-
</includes>
127-
<systemPropertyVariables>
128-
<config>run_parallel_test/parallel.conf.json</config>
129-
</systemPropertyVariables>
124+
<argLine>-javaagent:${com.browserstack:browserstack-java-sdk:jar}</argLine>
130125
</configuration>
131126
</plugin>
132127
</plugins>

0 commit comments

Comments
 (0)