Skip to content

Commit 2bc3faa

Browse files
committed
AAP-15642: Added Gradle support for Serenity
1 parent 3fda20c commit 2bc3faa

File tree

7 files changed

+160
-2
lines changed

7 files changed

+160
-2
lines changed

Diff for: .github/workflows/maven-workflow-run.yml

+16
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ jobs:
8282
cd ios
8383
mvn compile
8484
mvn verify -P sample-test
85+
- name: Run gradle task for android
86+
run: |
87+
cd android
88+
gradle clean sampleTest
89+
- name: Run gradle task sample-local-test for android
90+
run: |
91+
cd android
92+
gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk"
93+
- name: Run gradle task for ios
94+
run: |
95+
cd ios
96+
gradle clean sampleTest
97+
- name: Run gradle task sample-local-test for ios
98+
run: |
99+
cd ios
100+
gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.ipa"
85101
- if: always()
86102
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
87103
id: status-check-completed

Diff for: .gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ local.log
44
.idea
55
*/*/logs
66
*.iml
7-
logs/
7+
logs/
8+
bstack_*
9+
build
10+
.gradle
11+
gradle
12+
gradlew*

Diff for: README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ These code samples are currently based on:
2525
- If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
2626
- For installation, follow the instructions [here](https://maven.apache.org/install.html)
2727

28+
3. Gradle
29+
- If Gradle is not downloaded, download it from [here](https://gradle.org/releases/)
30+
- For installation, follow the instructions [here](https://gradle.org/install/)
31+
2832
### Install the dependencies
2933

3034
To install the dependencies, run :
@@ -50,7 +54,8 @@ Getting Started with Appium tests on BrowserStack couldn't be easier!
5054
### **Run first test :**
5155
5256
- Update `browserstack.yml` file at root level of [Android examples](android) or [iOS examples](ios) with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
53-
- Run `mvn test -P sample-test`
57+
- Run the following maven command `mvn test -P sample-test` to run in maven enviroment.
58+
- Run the following gradle command `gradle clean sampleTest` to run in gradle enviroment.
5459
5560
### **Use Local testing for apps that access resources hosted in development or testing environments :**
5661

Diff for: android/build.gradle

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
plugins {
2+
id 'java'
3+
id 'com.browserstack.gradle-sdk' version "1.1.2" // sdk plugin
4+
}
5+
6+
repositories { mavenCentral() }
7+
8+
dependencies {
9+
testImplementation "net.serenity-bdd:serenity-core:3.3.4"
10+
testImplementation "net.serenity-bdd:serenity-cucumber:3.3.4"
11+
testImplementation "net.serenity-bdd:serenity-screenplay:3.3.4"
12+
testImplementation "net.serenity-bdd:serenity-screenplay-webdriver:3.3.4"
13+
testImplementation "net.serenity-bdd:serenity-ensure:3.3.4"
14+
testImplementation "io.cucumber:cucumber-junit-platform-engine:7.8.1"
15+
testImplementation "org.junit.platform:junit-platform-suite:1.8.1"
16+
testImplementation "org.junit.jupiter:junit-jupiter:5.9.1"
17+
testImplementation "org.junit.vintage:junit-vintage-engine:5.8.2"
18+
testImplementation "org.assertj:assertj-core:3.23.1"
19+
implementation "org.seleniumhq.selenium:selenium-java:4.4.0"
20+
implementation "io.appium:java-client:8.1.1"
21+
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
22+
}
23+
24+
group = 'com.browserstack'
25+
version = '1.0-SNAPSHOT'
26+
description = 'serenity-browserstack'
27+
sourceCompatibility = '1.8'
28+
29+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
30+
31+
tasks.withType(JavaCompile) {
32+
options.encoding = 'UTF-8'
33+
}
34+
35+
tasks.withType(Test) {
36+
systemProperties = System.properties
37+
jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
38+
}
39+
40+
task sampleTest(type: Test) {
41+
dependsOn cleanTest
42+
include '/com/browserstack/cucumber/SampleTest.**'
43+
useJUnitPlatform()
44+
jvmArgs "-javaagent:${configurations.runtimeClasspath.files.find { it.name.contains('browserstack-java-sdk') }}"
45+
}
46+
task sampleLocalTest(type: Test) {
47+
dependsOn cleanTest
48+
include '/com/browserstack/cucumber/LocalTest.**'
49+
useJUnitPlatform()
50+
jvmArgs "-javaagent:${configurations.runtimeClasspath.files.find { it.name.contains('browserstack-java-sdk') }}"
51+
}

Diff for: android/settings.gradle

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pluginManagement {
2+
repositories {
3+
mavenCentral()
4+
mavenLocal()
5+
gradlePluginPortal()
6+
}
7+
8+
resolutionStrategy {
9+
eachPlugin {
10+
if (requested.id.id == "com.browserstack.gradle-sdk") {
11+
useModule("com.browserstack:gradle-sdk:1.1.2")
12+
}
13+
}
14+
}
15+
}

Diff for: ios/build.gradle

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
plugins {
2+
id 'java'
3+
id 'com.browserstack.gradle-sdk' version "1.1.2" // sdk plugin
4+
}
5+
6+
repositories { mavenCentral() }
7+
8+
dependencies {
9+
testImplementation "net.serenity-bdd:serenity-core:3.3.4"
10+
testImplementation "net.serenity-bdd:serenity-cucumber:3.3.4"
11+
testImplementation "net.serenity-bdd:serenity-screenplay:3.3.4"
12+
testImplementation "net.serenity-bdd:serenity-screenplay-webdriver:3.3.4"
13+
testImplementation "net.serenity-bdd:serenity-ensure:3.3.4"
14+
testImplementation "io.cucumber:cucumber-junit-platform-engine:7.8.1"
15+
testImplementation "org.junit.platform:junit-platform-suite:1.8.1"
16+
testImplementation "org.junit.jupiter:junit-jupiter:5.9.1"
17+
testImplementation "org.junit.vintage:junit-vintage-engine:5.8.2"
18+
testImplementation "org.assertj:assertj-core:3.23.1"
19+
implementation "org.seleniumhq.selenium:selenium-java:4.4.0"
20+
implementation "io.appium:java-client:8.1.1"
21+
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
22+
}
23+
24+
group = 'com.browserstack'
25+
version = '1.0-SNAPSHOT'
26+
description = 'serenity-browserstack'
27+
sourceCompatibility = '1.8'
28+
29+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
30+
31+
tasks.withType(JavaCompile) {
32+
options.encoding = 'UTF-8'
33+
}
34+
35+
tasks.withType(Test) {
36+
systemProperties = System.properties
37+
jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
38+
}
39+
40+
task sampleTest(type: Test) {
41+
dependsOn cleanTest
42+
include '/com/browserstack/cucumber/SampleTest.**'
43+
useJUnitPlatform()
44+
jvmArgs "-javaagent:${configurations.runtimeClasspath.files.find { it.name.contains('browserstack-java-sdk') }}"
45+
}
46+
task sampleLocalTest(type: Test) {
47+
dependsOn cleanTest
48+
include '/com/browserstack/cucumber/LocalTest.**'
49+
useJUnitPlatform()
50+
jvmArgs "-javaagent:${configurations.runtimeClasspath.files.find { it.name.contains('browserstack-java-sdk') }}"
51+
}

Diff for: ios/settings.gradle

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pluginManagement {
2+
repositories {
3+
mavenCentral()
4+
mavenLocal()
5+
gradlePluginPortal()
6+
}
7+
8+
resolutionStrategy {
9+
eachPlugin {
10+
if (requested.id.id == "com.browserstack.gradle-sdk") {
11+
useModule("com.browserstack:gradle-sdk:1.1.2")
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)