From 0052b561bd0ed622c5bbf772c385c2aa36629ee2 Mon Sep 17 00:00:00 2001 From: rhisav-25 Date: Fri, 28 Mar 2025 07:49:53 +0000 Subject: [PATCH 1/5] Added Gradle support for Cucumber framework --- .github/workflows/maven-workflow-run.yml | 16 +++++++ .gitignore | 5 ++ README.md | 7 ++- android/build.gradle | 59 ++++++++++++++++++++++++ ios/build.gradle | 59 ++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 android/build.gradle create mode 100644 ios/build.gradle diff --git a/.github/workflows/maven-workflow-run.yml b/.github/workflows/maven-workflow-run.yml index 6eef44b..96928df 100644 --- a/.github/workflows/maven-workflow-run.yml +++ b/.github/workflows/maven-workflow-run.yml @@ -82,6 +82,22 @@ jobs: cd ios mvn compile mvn test -P sample-test + - name: Run gradle task for android + run: | + cd android + gradle clean sampleTest + - name: Run gradle task sample-local-test for android + run: | + cd android + gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk" + - name: Run gradle task for ios + run: | + cd ios + gradle clean sampleTest + - name: Run gradle task sample-local-test for ios + run: | + cd ios + gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.ipa" - if: always() uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 id: status-check-completed diff --git a/.gitignore b/.gitignore index 5ffe1d3..83a7f51 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,8 @@ local.log **/logs/* reports/ logs/ +bstack_* +build +.gradle +gradle +gradlew* \ No newline at end of file diff --git a/README.md b/README.md index e2d488a..530c12d 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ This repository demonstrates how to run Appium tests in Cucumber Testng on Brows - If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi) - For installation, follow the instructions [here](https://maven.apache.org/install.html) +3. Gradle + - If Gradle is not downloaded, download it from [here](https://gradle.org/releases/) + - For installation, follow the instructions [here](https://gradle.org/install/) + ### Install the dependencies 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 ### **Run Sample test :** - Switch to one of the following directories: [Android examples](android) or [iOS examples](ios) -- Run the following maven command `mvn test -P sample-test` +- Run the following maven command `mvn test -P sample-test` to run in maven enviroment. +- Run the following gradle command `gradle clean sampleTest` to run in gradle enviroment. ### **Use Local testing for apps that access resources hosted in development or testing environments :** diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..ae20c6e --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,59 @@ +plugins { + id 'java' +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.seleniumhq.selenium:selenium-java:4.13.0' + testImplementation 'io.cucumber:cucumber-java:7.3.4' + testImplementation 'io.cucumber:cucumber-testng:7.3.4' + testImplementation 'io.cucumber:cucumber-core:7.3.4' + implementation "io.appium:java-client:8.6.0" + implementation "commons-io:commons-io:2.11.0" + implementation 'com.browserstack:browserstack-java-sdk:latest.release' +} + +group = 'com.browserstack' +version = '1.0-SNAPSHOT' +description = 'cucumber-java-browserstack' +sourceCompatibility = '1.8' +targetCompatibility = '1.8' + +def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +tasks.withType(Test) { + systemProperties = System.properties +} + +task sampleTest(type: Test) { + systemProperty "cucumber.publish.quiet", "true" + systemProperty "cucumber.features", "src/test/resources/features/test" + systemProperties System.getProperties() + useTestNG() { + dependsOn clean + useDefaultListeners = true + suites "src/test/resources/testng.xml" + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" + } + scanForTestClasses = false +} + +task sampleLocalTest(type: Test) { + systemProperty "cucumber.publish.quiet", "true" + systemProperty "cucumber.features", "src/test/resources/features/localtest" + systemProperties System.getProperties() + useTestNG() { + dependsOn clean + useDefaultListeners = true + suites "src/test/resources/testng.xml" + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" + } + scanForTestClasses = false +} \ No newline at end of file diff --git a/ios/build.gradle b/ios/build.gradle new file mode 100644 index 0000000..ae20c6e --- /dev/null +++ b/ios/build.gradle @@ -0,0 +1,59 @@ +plugins { + id 'java' +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.seleniumhq.selenium:selenium-java:4.13.0' + testImplementation 'io.cucumber:cucumber-java:7.3.4' + testImplementation 'io.cucumber:cucumber-testng:7.3.4' + testImplementation 'io.cucumber:cucumber-core:7.3.4' + implementation "io.appium:java-client:8.6.0" + implementation "commons-io:commons-io:2.11.0" + implementation 'com.browserstack:browserstack-java-sdk:latest.release' +} + +group = 'com.browserstack' +version = '1.0-SNAPSHOT' +description = 'cucumber-java-browserstack' +sourceCompatibility = '1.8' +targetCompatibility = '1.8' + +def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +tasks.withType(Test) { + systemProperties = System.properties +} + +task sampleTest(type: Test) { + systemProperty "cucumber.publish.quiet", "true" + systemProperty "cucumber.features", "src/test/resources/features/test" + systemProperties System.getProperties() + useTestNG() { + dependsOn clean + useDefaultListeners = true + suites "src/test/resources/testng.xml" + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" + } + scanForTestClasses = false +} + +task sampleLocalTest(type: Test) { + systemProperty "cucumber.publish.quiet", "true" + systemProperty "cucumber.features", "src/test/resources/features/localtest" + systemProperties System.getProperties() + useTestNG() { + dependsOn clean + useDefaultListeners = true + suites "src/test/resources/testng.xml" + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" + } + scanForTestClasses = false +} \ No newline at end of file From d0602f8e9bdfbee8f01729a7e3dec7bbdef8857b Mon Sep 17 00:00:00 2001 From: rhisav-25 Date: Thu, 3 Apr 2025 04:35:15 +0000 Subject: [PATCH 2/5] resolving comments for consistency --- .github/workflows/maven-workflow-run.yml | 8 ++++---- README.md | 26 ++++++++++++++++++------ android/build.gradle | 2 +- ios/build.gradle | 2 +- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/maven-workflow-run.yml b/.github/workflows/maven-workflow-run.yml index 96928df..ae93601 100644 --- a/.github/workflows/maven-workflow-run.yml +++ b/.github/workflows/maven-workflow-run.yml @@ -82,19 +82,19 @@ jobs: cd ios mvn compile mvn test -P sample-test - - name: Run gradle task for android + - name: Run gradle task for android run: | cd android gradle clean sampleTest - - name: Run gradle task sample-local-test for android + - name: Run gradle task sample-local-test for android run: | cd android gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk" - - name: Run gradle task for ios + - name: Run gradle task for ios run: | cd ios gradle clean sampleTest - - name: Run gradle task sample-local-test for ios + - name: Run gradle task sample-local-test for ios run: | cd ios gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.ipa" diff --git a/README.md b/README.md index 530c12d..b0b8022 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ This repository demonstrates how to run Appium tests in Cucumber Testng on Brows - For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable - 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/) -2. Maven +2. Maven (Only required if using Maven as the build tool) - If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi) - For installation, follow the instructions [here](https://maven.apache.org/install.html) -3. Gradle +3. Gradle (Only required if using Gradle as the build tool) - If Gradle is not downloaded, download it from [here](https://gradle.org/releases/) - For installation, follow the instructions [here](https://gradle.org/install/) @@ -46,8 +46,14 @@ Getting Started with Appium tests in Cucumber TestNg on BrowserStack couldn't be ### **Run Sample test :** - Switch to one of the following directories: [Android examples](android) or [iOS examples](ios) -- Run the following maven command `mvn test -P sample-test` to run in maven enviroment. -- Run the following gradle command `gradle clean sampleTest` to run in gradle enviroment. +- **For Maven:** Run the following command to execute tests in the Maven environment: + ```sh + mvn test -P sample-test + ``` +- **For Gradle:** Run the following command to execute tests in the Gradle environment: + ```sh + gradle clean sampleTest + ``` ### **Use Local testing for apps that access resources hosted in development or testing environments :** @@ -55,8 +61,16 @@ Getting Started with Appium tests in Cucumber TestNg on BrowserStack couldn't be ``` browserstackLocal: true ``` -- 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` - +- 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. + +- **For Maven:** Run the following command to execute tests in the Maven environment: + ```sh + mvn test -P sample-local-test + ``` +- **For Gradle:** Run the following command to execute tests in the Gradle environment: + ```sh + gradle clean sampleLocalTest + ``` **Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help) diff --git a/android/build.gradle b/android/build.gradle index ae20c6e..456977b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -56,4 +56,4 @@ task sampleLocalTest(type: Test) { jvmArgs "-javaagent:${browserstackSDKArtifact.file}" } scanForTestClasses = false -} \ No newline at end of file +} diff --git a/ios/build.gradle b/ios/build.gradle index ae20c6e..456977b 100644 --- a/ios/build.gradle +++ b/ios/build.gradle @@ -56,4 +56,4 @@ task sampleLocalTest(type: Test) { jvmArgs "-javaagent:${browserstackSDKArtifact.file}" } scanForTestClasses = false -} \ No newline at end of file +} From b6b4fde311904cdd79a8de8751fca515907b2962 Mon Sep 17 00:00:00 2001 From: rhisav-25 Date: Thu, 3 Apr 2025 04:36:51 +0000 Subject: [PATCH 3/5] minor correction --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 83a7f51..cb4802d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ bstack_* build .gradle gradle -gradlew* \ No newline at end of file +gradlew* From d00c909228609dcd6b76bef99f6244b9b04bac08 Mon Sep 17 00:00:00 2001 From: rhisav-25 Date: Fri, 4 Apr 2025 07:44:12 +0000 Subject: [PATCH 4/5] Trigger Semgrep scan From b8aab4140e5dce8c6affecb832884aa91215b093 Mon Sep 17 00:00:00 2001 From: rhisav-25 Date: Fri, 4 Apr 2025 09:03:04 +0000 Subject: [PATCH 5/5] Trigger Semgrep scan