Skip to content

Commit 0052b56

Browse files
committed
Added Gradle support for Cucumber framework
1 parent 5457090 commit 0052b56

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed

.github/workflows/maven-workflow-run.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ jobs:
8282
cd ios
8383
mvn compile
8484
mvn test -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

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ local.log
77
**/logs/*
88
reports/
99
logs/
10+
bstack_*
11+
build
12+
.gradle
13+
gradle
14+
gradlew*

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ This repository demonstrates how to run Appium tests in Cucumber Testng on Brows
1818
- If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
1919
- For installation, follow the instructions [here](https://maven.apache.org/install.html)
2020

21+
3. Gradle
22+
- If Gradle is not downloaded, download it from [here](https://gradle.org/releases/)
23+
- For installation, follow the instructions [here](https://gradle.org/install/)
24+
2125
### Install the dependencies
2226

2327
To install the dependencies for Android tests, run :
@@ -42,7 +46,8 @@ Getting Started with Appium tests in Cucumber TestNg on BrowserStack couldn't be
4246
### **Run Sample test :**
4347

4448
- Switch to one of the following directories: [Android examples](android) or [iOS examples](ios)
45-
- Run the following maven command `mvn test -P sample-test`
49+
- Run the following maven command `mvn test -P sample-test` to run in maven enviroment.
50+
- Run the following gradle command `gradle clean sampleTest` to run in gradle enviroment.
4651

4752
### **Use Local testing for apps that access resources hosted in development or testing environments :**
4853

android/build.gradle

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
implementation 'org.seleniumhq.selenium:selenium-java:4.13.0'
11+
testImplementation 'io.cucumber:cucumber-java:7.3.4'
12+
testImplementation 'io.cucumber:cucumber-testng:7.3.4'
13+
testImplementation 'io.cucumber:cucumber-core:7.3.4'
14+
implementation "io.appium:java-client:8.6.0"
15+
implementation "commons-io:commons-io:2.11.0"
16+
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
17+
}
18+
19+
group = 'com.browserstack'
20+
version = '1.0-SNAPSHOT'
21+
description = 'cucumber-java-browserstack'
22+
sourceCompatibility = '1.8'
23+
targetCompatibility = '1.8'
24+
25+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
26+
27+
tasks.withType(JavaCompile) {
28+
options.encoding = 'UTF-8'
29+
}
30+
31+
tasks.withType(Test) {
32+
systemProperties = System.properties
33+
}
34+
35+
task sampleTest(type: Test) {
36+
systemProperty "cucumber.publish.quiet", "true"
37+
systemProperty "cucumber.features", "src/test/resources/features/test"
38+
systemProperties System.getProperties()
39+
useTestNG() {
40+
dependsOn clean
41+
useDefaultListeners = true
42+
suites "src/test/resources/testng.xml"
43+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
44+
}
45+
scanForTestClasses = false
46+
}
47+
48+
task sampleLocalTest(type: Test) {
49+
systemProperty "cucumber.publish.quiet", "true"
50+
systemProperty "cucumber.features", "src/test/resources/features/localtest"
51+
systemProperties System.getProperties()
52+
useTestNG() {
53+
dependsOn clean
54+
useDefaultListeners = true
55+
suites "src/test/resources/testng.xml"
56+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
57+
}
58+
scanForTestClasses = false
59+
}

ios/build.gradle

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
implementation 'org.seleniumhq.selenium:selenium-java:4.13.0'
11+
testImplementation 'io.cucumber:cucumber-java:7.3.4'
12+
testImplementation 'io.cucumber:cucumber-testng:7.3.4'
13+
testImplementation 'io.cucumber:cucumber-core:7.3.4'
14+
implementation "io.appium:java-client:8.6.0"
15+
implementation "commons-io:commons-io:2.11.0"
16+
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
17+
}
18+
19+
group = 'com.browserstack'
20+
version = '1.0-SNAPSHOT'
21+
description = 'cucumber-java-browserstack'
22+
sourceCompatibility = '1.8'
23+
targetCompatibility = '1.8'
24+
25+
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
26+
27+
tasks.withType(JavaCompile) {
28+
options.encoding = 'UTF-8'
29+
}
30+
31+
tasks.withType(Test) {
32+
systemProperties = System.properties
33+
}
34+
35+
task sampleTest(type: Test) {
36+
systemProperty "cucumber.publish.quiet", "true"
37+
systemProperty "cucumber.features", "src/test/resources/features/test"
38+
systemProperties System.getProperties()
39+
useTestNG() {
40+
dependsOn clean
41+
useDefaultListeners = true
42+
suites "src/test/resources/testng.xml"
43+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
44+
}
45+
scanForTestClasses = false
46+
}
47+
48+
task sampleLocalTest(type: Test) {
49+
systemProperty "cucumber.publish.quiet", "true"
50+
systemProperty "cucumber.features", "src/test/resources/features/localtest"
51+
systemProperties System.getProperties()
52+
useTestNG() {
53+
dependsOn clean
54+
useDefaultListeners = true
55+
suites "src/test/resources/testng.xml"
56+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
57+
}
58+
scanForTestClasses = false
59+
}

0 commit comments

Comments
 (0)