Skip to content

Commit da9ef71

Browse files
authored
Merge pull request #5 from rhisav-25/AAP-15642-gradle-support-cucumber
Added Gradle support for Cucumber framework
2 parents 5457090 + b8aab41 commit da9ef71

File tree

5 files changed

+162
-4
lines changed

5 files changed

+162
-4
lines changed

.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 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

+5
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

+23-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ This repository demonstrates how to run Appium tests in Cucumber Testng on Brows
1414
- For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
1515
- For Mac and Linux, run `java -version` to see what java version is pre-installed. If you want a different version download from [here](https://java.com/en/download/)
1616

17-
2. Maven
17+
2. Maven (Only required if using Maven as the build tool)
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 (Only required if using Gradle as the build tool)
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,16 +46,31 @@ 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+
- **For Maven:** Run the following command to execute tests in the Maven environment:
50+
```sh
51+
mvn test -P sample-test
52+
```
53+
- **For Gradle:** Run the following command to execute tests in the Gradle environment:
54+
```sh
55+
gradle clean sampleTest
56+
```
4657

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

4960
- Simply configure the `browserstackLocal` parameter in the `browserstack.yml` file accordingly in [Android examples](android) or [iOS examples](ios).
5061
```
5162
browserstackLocal: true
5263
```
53-
- You can use the `LocalSample` app provided in both folder [Android examples](android) or [iOS examples](ios) to run your test. Change the app parameter in the `browserstack.yml` file and run the tests with the following command: `mvn test -P sample-local-test`
54-
64+
- You can use the `LocalSample` app provided in both folder [Android examples](android) or [iOS examples](ios) to run your test. Change the app parameter in the `browserstack.yml` file.
65+
66+
- **For Maven:** Run the following command to execute tests in the Maven environment:
67+
```sh
68+
mvn test -P sample-local-test
69+
```
70+
- **For Gradle:** Run the following command to execute tests in the Gradle environment:
71+
```sh
72+
gradle clean sampleLocalTest
73+
```
5574
5675
**Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help)
5776

android/build.gradle

+59
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

+59
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)