From ac26750923f3e21f7fb29d1fb9c9d898ecb06ec0 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 23 Aug 2024 11:41:52 +0530 Subject: [PATCH 01/24] SDKAD-153 Added gradle config for JUnit5 --- junit-5/README.md | 40 +++++++++++++++++++++++++++++++++++++-- junit-5/build.gradle | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 junit-5/build.gradle diff --git a/junit-5/README.md b/junit-5/README.md index bd917a0..2cb99ce 100644 --- a/junit-5/README.md +++ b/junit-5/README.md @@ -4,16 +4,52 @@ Master branch contains **Selenium 4 - W3C protocol** samples, for **Selenium 3** -## Setup +## Using Maven +### Setup * Clone the repo * Install dependencies `mvn install` * Update `browserstack.yml` files inside the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings). -## Running your tests +### Running your tests * To run a single test, run `mvn test -P single` * To run local tests, run `mvn test -P local` Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) +## Using Gradle + +### Prerequisites +- If using Gradle, Java v9+ is required. + +### Setup +- Clone the repository +- Install dependencies `gradle build` + +### Running your tests +- To run the single test, run `gradle single` +- To run local tests, run `gradle local` + +Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) + +### Integrate your test suite + +This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: + +* Following are the changes required in `gradle.build` - + * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies + * Fetch Artifact Information and add `jvmArgs` property in tasks *SingleTest* and *LocalTest* : + ``` + def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } + + task single(type: Test) { + dependsOn cleanTest + include '**/*BStackSampleTest.*' + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" + useJUnitPlatform() + } + ``` + +* Install dependencies `gradle build` + ## Notes * You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) diff --git a/junit-5/build.gradle b/junit-5/build.gradle new file mode 100644 index 0000000..47da4b3 --- /dev/null +++ b/junit-5/build.gradle @@ -0,0 +1,45 @@ +plugins { + id 'java' +} + +repositories { mavenCentral() } + +dependencies { + implementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' + implementation 'org.junit.jupiter:junit-jupiter-engine:5.9.1' + implementation 'org.junit.platform:junit-platform-console:1.8.1' + implementation 'org.seleniumhq.selenium:selenium-java:4.22.0' + implementation 'com.browserstack:browserstack-local-java:1.0.6' + implementation 'com.googlecode.json-simple:json-simple:1.1.1' + implementation 'org.yaml:snakeyaml:2.2' + implementation 'com.browserstack:browserstack-java-sdk:latest.release' +} + +group = 'com.browserstack' +version = '1.0-SNAPSHOT' +description = 'junit-browserstack' +sourceCompatibility = '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 single(type: Test) { + dependsOn cleanTest + include '**/*BStackSampleTest.*' + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" + useJUnitPlatform() +} + +task local(type: Test) { + dependsOn cleanTest + include '**/*BStackLocalTest.*' + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" + useJUnitPlatform() +} From d8cf4830f4dcbda1fd17dcf8b2b3143ed85b4f2e Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 23 Aug 2024 12:00:11 +0530 Subject: [PATCH 02/24] SDKAD-153 Removed implementation 'com.browserstack:browserstack-local-java:1.0.6' dependency --- junit-5/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/junit-5/build.gradle b/junit-5/build.gradle index 47da4b3..aa95a68 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -9,7 +9,6 @@ dependencies { implementation 'org.junit.jupiter:junit-jupiter-engine:5.9.1' implementation 'org.junit.platform:junit-platform-console:1.8.1' implementation 'org.seleniumhq.selenium:selenium-java:4.22.0' - implementation 'com.browserstack:browserstack-local-java:1.0.6' implementation 'com.googlecode.json-simple:json-simple:1.1.1' implementation 'org.yaml:snakeyaml:2.2' implementation 'com.browserstack:browserstack-java-sdk:latest.release' From 8773751b2c44896fc3d876c78c33933900b5ea1f Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 23 Aug 2024 13:12:50 +0530 Subject: [PATCH 03/24] SDKAD-153 Removed dependencies that are not needed --- junit-5/build.gradle | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/junit-5/build.gradle b/junit-5/build.gradle index aa95a68..a9f0412 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -7,10 +7,7 @@ repositories { mavenCentral() } dependencies { implementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' implementation 'org.junit.jupiter:junit-jupiter-engine:5.9.1' - implementation 'org.junit.platform:junit-platform-console:1.8.1' implementation 'org.seleniumhq.selenium:selenium-java:4.22.0' - implementation 'com.googlecode.json-simple:json-simple:1.1.1' - implementation 'org.yaml:snakeyaml:2.2' implementation 'com.browserstack:browserstack-java-sdk:latest.release' } @@ -19,8 +16,6 @@ version = '1.0-SNAPSHOT' description = 'junit-browserstack' sourceCompatibility = '1.8' -def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } - tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } @@ -29,16 +24,22 @@ tasks.withType(Test) { systemProperties = System.properties } +tasks.withType(Test).configureEach { task -> + doFirst { + configurations.testRuntimeClasspath + ?.find { it.name.startsWith("browserstack-java-sdk") } + ?.with { task.jvmArgs += "-javaagent:$it" } + } +} + task single(type: Test) { dependsOn cleanTest include '**/*BStackSampleTest.*' - jvmArgs "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } task local(type: Test) { dependsOn cleanTest include '**/*BStackLocalTest.*' - jvmArgs "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } From 75b4d6b08615cede8b977288c11bb2af26d33d7d Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 23 Aug 2024 14:41:46 +0530 Subject: [PATCH 04/24] SDKAD-153 Made gradle config similar to TestNg config --- junit-5/build.gradle | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/junit-5/build.gradle b/junit-5/build.gradle index a9f0412..090b079 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -16,6 +16,8 @@ version = '1.0-SNAPSHOT' description = 'junit-browserstack' sourceCompatibility = '1.8' +def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } + tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } @@ -24,22 +26,16 @@ tasks.withType(Test) { systemProperties = System.properties } -tasks.withType(Test).configureEach { task -> - doFirst { - configurations.testRuntimeClasspath - ?.find { it.name.startsWith("browserstack-java-sdk") } - ?.with { task.jvmArgs += "-javaagent:$it" } - } -} - task single(type: Test) { dependsOn cleanTest include '**/*BStackSampleTest.*' + jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } task local(type: Test) { dependsOn cleanTest include '**/*BStackLocalTest.*' + jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } From 1fc0bab799a623491c487a98c33cfd36b5182ec5 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 23 Aug 2024 16:33:26 +0530 Subject: [PATCH 05/24] SDKAD-153 Updated gradle config --- junit-5/build.gradle | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/junit-5/build.gradle b/junit-5/build.gradle index 090b079..02cee56 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -16,26 +16,27 @@ version = '1.0-SNAPSHOT' description = 'junit-browserstack' sourceCompatibility = '1.8' -def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } +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 +tasks.withType(Test).configureEach { task -> + browserstackSDKArtifact?.file?.with { + task.systemProperties = System.properties + task.jvmArgs += "-javaagent:$it" + } } task single(type: Test) { dependsOn cleanTest include '**/*BStackSampleTest.*' - jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } task local(type: Test) { dependsOn cleanTest include '**/*BStackLocalTest.*' - jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } From 066f358a79bc9839e848fee4cb91fee3cb6d0362 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 23 Aug 2024 16:35:34 +0530 Subject: [PATCH 06/24] SDKAD-153 Updated gradle config in readme --- junit-5/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/junit-5/README.md b/junit-5/README.md index 2cb99ce..2ac58cf 100644 --- a/junit-5/README.md +++ b/junit-5/README.md @@ -39,11 +39,15 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t * Fetch Artifact Information and add `jvmArgs` property in tasks *SingleTest* and *LocalTest* : ``` def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } - + tasks.withType(Test).configureEach { task -> + browserstackSDKArtifact?.file?.with { + task.systemProperties = System.properties + task.jvmArgs += "-javaagent:$it" + } + } task single(type: Test) { dependsOn cleanTest include '**/*BStackSampleTest.*' - jvmArgs "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } ``` From 9301ae22f52b459e3194cf6dfb14c1ce5ebfb7c5 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Mon, 26 Aug 2024 18:07:49 +0530 Subject: [PATCH 07/24] SDKAD-153 Added gradle config for junit4 --- junit-4/README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- junit-4/build.gradle | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 junit-4/build.gradle diff --git a/junit-4/README.md b/junit-4/README.md index 856f86c..4c03a2b 100644 --- a/junit-4/README.md +++ b/junit-4/README.md @@ -5,17 +5,56 @@ ![JUnit](http://junit.org/junit4/images/junit-logo.png) -## Setup +## Using Maven + +### Setup * Clone the repo * Install dependencies `mvn install` * Update `browserstack.yml` files inside the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings). -## Running your tests +### Running your tests * To run a parallel test, run `mvn test -P sample` * To run local tests, set `browserStackLocal: true` in `browserstack.yml` and run `mvn test -P local` Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) + +## Using Gradle + +### Prerequisites +- If using Gradle, Java v9+ is required. + +### Setup +* Clone the repo +* Update `browserstack.yml` files inside the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings). + +### Running your tests +* To run a parallel test, run `gradle sample` +* To run local tests, set `browserStackLocal: true` in `browserstack.yml` and run `gradle local` + +Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) + +### Integrate your test suite + +This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: + +* Following are the changes required in `build.gradle` - + * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies + * Fetch Artifact Information and add `jvmArgs` property in tasks *Sample* and *Local* : + ``` + def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } + + task sample(type: Test) { + useJUnit() { + dependsOn cleanTest + include '**/*BStackSampleTest.*' + jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" + } + } + ``` + +* Install dependencies and run the test `gradle sample` + ## Notes * You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) * To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/java#setting-os-and-browser) diff --git a/junit-4/build.gradle b/junit-4/build.gradle new file mode 100644 index 0000000..8db08af --- /dev/null +++ b/junit-4/build.gradle @@ -0,0 +1,42 @@ +plugins { + id 'java' +} + +repositories { mavenCentral() } + +dependencies { + implementation 'junit:junit:4.13.2' + implementation 'org.seleniumhq.selenium:selenium-java:4.1.4' + implementation 'org.yaml:snakeyaml:2.2' + implementation 'com.browserstack:browserstack-java-sdk:latest.release' +} + +group = 'com.browserstack' +version = '1.0-SNAPSHOT' +description = 'junit-browserstack' +sourceCompatibility = '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 + jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" +} + +task sample(type: Test) { + useJUnit() { + dependsOn cleanTest + include '**/*BStackSampleTest.*' + } +} + +task local(type: Test) { + useJUnit() { + dependsOn cleanTest + include '**/*BStackLocalTest.*' + } +} From c07740e6edb200614bd9f4c7c76915650b40ad94 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Mon, 26 Aug 2024 18:18:19 +0530 Subject: [PATCH 08/24] SDKAD-153 Updated readme for gradle config for JUnit5 --- junit-5/README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/junit-5/README.md b/junit-5/README.md index 2ac58cf..6f1829b 100644 --- a/junit-5/README.md +++ b/junit-5/README.md @@ -5,6 +5,7 @@ Master branch contains **Selenium 4 - W3C protocol** samples, for **Selenium 3** ## Using Maven + ### Setup * Clone the repo * Install dependencies `mvn install` @@ -15,6 +16,7 @@ Master branch contains **Selenium 4 - W3C protocol** samples, for **Selenium 3** * To run local tests, run `mvn test -P local` Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) + ## Using Gradle ### Prerequisites @@ -39,15 +41,11 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t * Fetch Artifact Information and add `jvmArgs` property in tasks *SingleTest* and *LocalTest* : ``` def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } - tasks.withType(Test).configureEach { task -> - browserstackSDKArtifact?.file?.with { - task.systemProperties = System.properties - task.jvmArgs += "-javaagent:$it" - } - } + task single(type: Test) { dependsOn cleanTest include '**/*BStackSampleTest.*' + jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" useJUnitPlatform() } ``` From 710f345cfcd628f1c06414cc5321d894f4b2f3d5 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 30 Aug 2024 18:13:21 +0530 Subject: [PATCH 09/24] SDKAD-153 Added gradle test run to github workflow --- .github/workflows/maven-workflow-run.yml | 8 ++++++++ junit-4/build.gradle | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-workflow-run.yml b/.github/workflows/maven-workflow-run.yml index 7c9a66c..2c1c32a 100644 --- a/.github/workflows/maven-workflow-run.yml +++ b/.github/workflows/maven-workflow-run.yml @@ -67,6 +67,14 @@ jobs: cd junit-4 mvn compile mvn test -P local + - name: Run gradle task sampleTest + run: | + cd junit-4 + gradle clean sampleTest + - name: Run gradle task sampleLocalTest + run: | + cd junit-4 + gradle clean sampleLocalTest - name: Run mvn test for junit-5 run: | cd junit-5 diff --git a/junit-4/build.gradle b/junit-4/build.gradle index 8db08af..7f0ab23 100644 --- a/junit-4/build.gradle +++ b/junit-4/build.gradle @@ -27,14 +27,14 @@ tasks.withType(Test) { jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" } -task sample(type: Test) { +task sampleTest(type: Test) { useJUnit() { dependsOn cleanTest include '**/*BStackSampleTest.*' } } -task local(type: Test) { +task sampleLocalTest(type: Test) { useJUnit() { dependsOn cleanTest include '**/*BStackLocalTest.*' From 6d784e97acd61bfb3056d6a6b754d2fbeaa4d498 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 30 Aug 2024 18:14:29 +0530 Subject: [PATCH 10/24] SDKAD-153 Added gradle test run to github workflow --- .github/workflows/maven-workflow-run.yml | 8 ++++++++ junit-5/build.gradle | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-workflow-run.yml b/.github/workflows/maven-workflow-run.yml index 7c9a66c..9ff52fc 100644 --- a/.github/workflows/maven-workflow-run.yml +++ b/.github/workflows/maven-workflow-run.yml @@ -82,6 +82,14 @@ jobs: cd junit-5 mvn compile mvn test -P local + - name: Run gradle task sampleTest + run: | + cd junit-5 + gradle clean sampleTest + - name: Run gradle task sampleLocalTest + run: | + cd junit-5 + gradle clean sampleLocalTest - if: always() uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 id: status-check-completed diff --git a/junit-5/build.gradle b/junit-5/build.gradle index 02cee56..07bd022 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -29,13 +29,13 @@ tasks.withType(Test).configureEach { task -> } } -task single(type: Test) { +task sampleTest(type: Test) { dependsOn cleanTest include '**/*BStackSampleTest.*' useJUnitPlatform() } -task local(type: Test) { +task sampleLocalTest(type: Test) { dependsOn cleanTest include '**/*BStackLocalTest.*' useJUnitPlatform() From d26e7ac80187be1be6b8ff6b93eceb2af471d813 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 30 Aug 2024 18:26:47 +0530 Subject: [PATCH 11/24] SDKAD-153 Updated task name in readme --- junit-5/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/junit-5/README.md b/junit-5/README.md index 6f1829b..9e8d805 100644 --- a/junit-5/README.md +++ b/junit-5/README.md @@ -27,8 +27,8 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu - Install dependencies `gradle build` ### Running your tests -- To run the single test, run `gradle single` -- To run local tests, run `gradle local` +- To run the single test, run `gradle sampleTest` +- To run local tests, run `gradle sampleLocalTest` Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) @@ -42,7 +42,7 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t ``` def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } - task single(type: Test) { + task sampleTest(type: Test) { dependsOn cleanTest include '**/*BStackSampleTest.*' jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" From 7192a4d37816076354517788e43c5c8601940d49 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Fri, 30 Aug 2024 18:27:56 +0530 Subject: [PATCH 12/24] SDKAD-153 Updated task name in readme --- junit-4/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/junit-4/README.md b/junit-4/README.md index 4c03a2b..38e7da0 100644 --- a/junit-4/README.md +++ b/junit-4/README.md @@ -29,8 +29,8 @@ * Update `browserstack.yml` files inside the root directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings). ### Running your tests -* To run a parallel test, run `gradle sample` -* To run local tests, set `browserStackLocal: true` in `browserstack.yml` and run `gradle local` +* To run a parallel test, run `gradle sampleTest` +* To run local tests, set `browserStackLocal: true` in `browserstack.yml` and run `gradle sampleLocalTest` Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) @@ -44,7 +44,7 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t ``` def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } - task sample(type: Test) { + task sampleTest(type: Test) { useJUnit() { dependsOn cleanTest include '**/*BStackSampleTest.*' From 0eb4c21e0c0c749a8e9e06ce7784c3c506f1c26a Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Tue, 8 Oct 2024 16:58:39 +0530 Subject: [PATCH 13/24] Added config for gradle plugin --- junit-5/build.gradle | 1 + junit-5/settings.gradle | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 junit-5/settings.gradle diff --git a/junit-5/build.gradle b/junit-5/build.gradle index 07bd022..a1dfffd 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java' + id 'com.browserstack.gradle-sdk' version "1.0.0" // sdk plugin } repositories { mavenCentral() } diff --git a/junit-5/settings.gradle b/junit-5/settings.gradle new file mode 100644 index 0000000..2a39923 --- /dev/null +++ b/junit-5/settings.gradle @@ -0,0 +1,15 @@ +pluginManagement { + repositories { + mavenCentral() + mavenLocal() + gradlePluginPortal() + } + + resolutionStrategy { + eachPlugin { + if (requested.id.id == "com.browserstack.gradle-sdk") { + useModule("com.browserstack:gradle-sdk:1.0.0") + } + } + } +} From 41aa1cf7007e32e5f25b6d11e5a8173219b65556 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Tue, 8 Oct 2024 17:00:24 +0530 Subject: [PATCH 14/24] Added config for gradle plugin --- junit-4/build.gradle | 1 + junit-4/settings.gradle | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 junit-4/settings.gradle diff --git a/junit-4/build.gradle b/junit-4/build.gradle index 7f0ab23..d647536 100644 --- a/junit-4/build.gradle +++ b/junit-4/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java' + id 'com.browserstack.gradle-sdk' version "1.0.0" // sdk plugin } repositories { mavenCentral() } diff --git a/junit-4/settings.gradle b/junit-4/settings.gradle new file mode 100644 index 0000000..2a39923 --- /dev/null +++ b/junit-4/settings.gradle @@ -0,0 +1,15 @@ +pluginManagement { + repositories { + mavenCentral() + mavenLocal() + gradlePluginPortal() + } + + resolutionStrategy { + eachPlugin { + if (requested.id.id == "com.browserstack.gradle-sdk") { + useModule("com.browserstack:gradle-sdk:1.0.0") + } + } + } +} From b30cb0c8e8dc2d6d5707d41df749a8c82d37d1b9 Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Tue, 8 Oct 2024 17:11:51 +0530 Subject: [PATCH 15/24] Updated readme to add gradle plugin for integration --- junit-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/junit-4/README.md b/junit-4/README.md index 38e7da0..3979bb7 100644 --- a/junit-4/README.md +++ b/junit-4/README.md @@ -39,6 +39,7 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: * Following are the changes required in `build.gradle` - + * Add `id 'com.browserstack.gradle-sdk' version "1.0.0"` in plugins * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies * Fetch Artifact Information and add `jvmArgs` property in tasks *Sample* and *Local* : ``` From 49710a3b237f6396f65b1c61ba65a6b914fc45ca Mon Sep 17 00:00:00 2001 From: Hrithik Katiyar Date: Tue, 8 Oct 2024 17:13:06 +0530 Subject: [PATCH 16/24] Updated readme to add gradle plugin for integration --- junit-5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/junit-5/README.md b/junit-5/README.md index 9e8d805..5750187 100644 --- a/junit-5/README.md +++ b/junit-5/README.md @@ -37,6 +37,7 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: * Following are the changes required in `gradle.build` - + * Add `id 'com.browserstack.gradle-sdk' version "1.0.0"` in plugins * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies * Fetch Artifact Information and add `jvmArgs` property in tasks *SingleTest* and *LocalTest* : ``` From 7e03b8e742477e78463fc034e6f4c423dcd34f4b Mon Sep 17 00:00:00 2001 From: Aaryan Date: Wed, 22 Jan 2025 17:01:20 +0530 Subject: [PATCH 17/24] add gradle in gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 87f8a89..272a376 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ local.log *.png *.txt **/logs +bstack_* +gradlew* +gradle From d352b8a3ad676715d9c4d08c43e834d7e91f6813 Mon Sep 17 00:00:00 2001 From: Aaryan Date: Wed, 22 Jan 2025 17:01:38 +0530 Subject: [PATCH 18/24] exclude java 8 for mac os latest --- .github/workflows/maven-workflow-run.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/maven-workflow-run.yml b/.github/workflows/maven-workflow-run.yml index 5b00b10..4f83b92 100644 --- a/.github/workflows/maven-workflow-run.yml +++ b/.github/workflows/maven-workflow-run.yml @@ -19,6 +19,9 @@ jobs: matrix: java: [ '8', '11', '17' ] os: [ 'macos-latest', 'windows-latest', 'ubuntu-latest' ] + exclude: + - java: '8' + os: 'macos-latest' name: JUnit Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample env: BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} From d821c4aeffb25e37fea2786aba189359ea5dae7a Mon Sep 17 00:00:00 2001 From: Aaryan Date: Wed, 22 Jan 2025 17:02:12 +0530 Subject: [PATCH 19/24] Fix gradle-sdk plugin version for junit4 --- junit-4/build.gradle | 2 +- junit-4/settings.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/junit-4/build.gradle b/junit-4/build.gradle index d647536..fce6feb 100644 --- a/junit-4/build.gradle +++ b/junit-4/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'com.browserstack.gradle-sdk' version "1.0.0" // sdk plugin + id 'com.browserstack.gradle-sdk' version "1.1.2" // sdk plugin } repositories { mavenCentral() } diff --git a/junit-4/settings.gradle b/junit-4/settings.gradle index 2a39923..3e5b662 100644 --- a/junit-4/settings.gradle +++ b/junit-4/settings.gradle @@ -8,7 +8,7 @@ pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.id == "com.browserstack.gradle-sdk") { - useModule("com.browserstack:gradle-sdk:1.0.0") + useModule("com.browserstack:gradle-sdk:1.1.2") } } } From e9f40cf12015d224c3c218e2144a8998de9c6f1b Mon Sep 17 00:00:00 2001 From: Aaryan Date: Wed, 22 Jan 2025 17:02:51 +0530 Subject: [PATCH 20/24] Fix gradle-sdk plugin version for junit5 --- junit-5/build.gradle | 2 +- junit-5/settings.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/junit-5/build.gradle b/junit-5/build.gradle index a1dfffd..36bda87 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'com.browserstack.gradle-sdk' version "1.0.0" // sdk plugin + id 'com.browserstack.gradle-sdk' version "1.1.2" // sdk plugin } repositories { mavenCentral() } diff --git a/junit-5/settings.gradle b/junit-5/settings.gradle index 2a39923..3e5b662 100644 --- a/junit-5/settings.gradle +++ b/junit-5/settings.gradle @@ -8,7 +8,7 @@ pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.id == "com.browserstack.gradle-sdk") { - useModule("com.browserstack:gradle-sdk:1.0.0") + useModule("com.browserstack:gradle-sdk:1.1.2") } } } From bd2b8d3348db2f049e5cc428fd149b6c6ec75907 Mon Sep 17 00:00:00 2001 From: Aaryan Date: Wed, 22 Jan 2025 17:03:26 +0530 Subject: [PATCH 21/24] fix readme for new plugin for junit 4 and 5 --- junit-4/README.md | 12 +++++++++++- junit-5/README.md | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/junit-4/README.md b/junit-4/README.md index 3979bb7..a118fd8 100644 --- a/junit-4/README.md +++ b/junit-4/README.md @@ -39,7 +39,7 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: * Following are the changes required in `build.gradle` - - * Add `id 'com.browserstack.gradle-sdk' version "1.0.0"` in plugins + * Add `id 'com.browserstack.gradle-sdk' version "1.1.2"` in plugins * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies * Fetch Artifact Information and add `jvmArgs` property in tasks *Sample* and *Local* : ``` @@ -53,6 +53,16 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t } } ``` +* Following are the changes required in `settings.gradle` - + * Add `resolutionStrategy` inside `plugpluginManagement` + * Inside `resoluitonStrategy` add the plugin `id` as `com.browserstack.gradle-sdk` along with module `version` + ``` + eachPlugin { + if (requested.id.id == "com.browserstack.gradle-sdk") { + useModule("com.browserstack:gradle-sdk:1.1.2") + } + } + ``` * Install dependencies and run the test `gradle sample` diff --git a/junit-5/README.md b/junit-5/README.md index 5750187..f65fc84 100644 --- a/junit-5/README.md +++ b/junit-5/README.md @@ -37,7 +37,7 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: * Following are the changes required in `gradle.build` - - * Add `id 'com.browserstack.gradle-sdk' version "1.0.0"` in plugins + * Add `id 'com.browserstack.gradle-sdk' version "1.1.2"` in plugins * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies * Fetch Artifact Information and add `jvmArgs` property in tasks *SingleTest* and *LocalTest* : ``` @@ -50,6 +50,16 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t useJUnitPlatform() } ``` + * Following are the changes required in `settings.gradle` - + * Add `resolutionStrategy` inside `plugpluginManagement` + * Inside `resoluitonStrategy` add the plugin `id` as `com.browserstack.gradle-sdk` along with module `version` + ``` + eachPlugin { + if (requested.id.id == "com.browserstack.gradle-sdk") { + useModule("com.browserstack:gradle-sdk:1.1.2") + } + } + ``` * Install dependencies `gradle build` From 55976879c9b0c6a16dade540827f35e9e6a16a11 Mon Sep 17 00:00:00 2001 From: Aaryan Date: Wed, 22 Jan 2025 17:49:43 +0530 Subject: [PATCH 22/24] fix selenium java version for supporting java 8 --- junit-5/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/junit-5/build.gradle b/junit-5/build.gradle index 36bda87..966f5ed 100644 --- a/junit-5/build.gradle +++ b/junit-5/build.gradle @@ -8,7 +8,7 @@ repositories { mavenCentral() } dependencies { implementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' implementation 'org.junit.jupiter:junit-jupiter-engine:5.9.1' - implementation 'org.seleniumhq.selenium:selenium-java:4.22.0' + implementation 'org.seleniumhq.selenium:selenium-java:4.1.4' implementation 'com.browserstack:browserstack-java-sdk:latest.release' } From c6c9acf8dfab1e5ec4a88b46f24fc203f741b44f Mon Sep 17 00:00:00 2001 From: Aaryan Date: Wed, 22 Jan 2025 19:07:00 +0530 Subject: [PATCH 23/24] fix readme to match existing structure --- junit-4/README.md | 31 ------------------------------- junit-5/README.md | 31 ------------------------------- 2 files changed, 62 deletions(-) diff --git a/junit-4/README.md b/junit-4/README.md index a118fd8..4aa029c 100644 --- a/junit-4/README.md +++ b/junit-4/README.md @@ -34,37 +34,6 @@ Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) -### Integrate your test suite - -This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: - -* Following are the changes required in `build.gradle` - - * Add `id 'com.browserstack.gradle-sdk' version "1.1.2"` in plugins - * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies - * Fetch Artifact Information and add `jvmArgs` property in tasks *Sample* and *Local* : - ``` - def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } - - task sampleTest(type: Test) { - useJUnit() { - dependsOn cleanTest - include '**/*BStackSampleTest.*' - jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" - } - } - ``` -* Following are the changes required in `settings.gradle` - - * Add `resolutionStrategy` inside `plugpluginManagement` - * Inside `resoluitonStrategy` add the plugin `id` as `com.browserstack.gradle-sdk` along with module `version` - ``` - eachPlugin { - if (requested.id.id == "com.browserstack.gradle-sdk") { - useModule("com.browserstack:gradle-sdk:1.1.2") - } - } - ``` - -* Install dependencies and run the test `gradle sample` ## Notes * You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) diff --git a/junit-5/README.md b/junit-5/README.md index f65fc84..bb68ee5 100644 --- a/junit-5/README.md +++ b/junit-5/README.md @@ -32,37 +32,6 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) -### Integrate your test suite - -This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: - -* Following are the changes required in `gradle.build` - - * Add `id 'com.browserstack.gradle-sdk' version "1.1.2"` in plugins - * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies - * Fetch Artifact Information and add `jvmArgs` property in tasks *SingleTest* and *LocalTest* : - ``` - def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } - - task sampleTest(type: Test) { - dependsOn cleanTest - include '**/*BStackSampleTest.*' - jvmArgs += "-javaagent:${browserstackSDKArtifact.file}" - useJUnitPlatform() - } - ``` - * Following are the changes required in `settings.gradle` - - * Add `resolutionStrategy` inside `plugpluginManagement` - * Inside `resoluitonStrategy` add the plugin `id` as `com.browserstack.gradle-sdk` along with module `version` - ``` - eachPlugin { - if (requested.id.id == "com.browserstack.gradle-sdk") { - useModule("com.browserstack:gradle-sdk:1.1.2") - } - } - ``` - -* Install dependencies `gradle build` - ## Notes * You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) From 0f8836335502cef20746309de69ca379b9765c17 Mon Sep 17 00:00:00 2001 From: Aaryan Date: Fri, 24 Jan 2025 18:55:00 +0530 Subject: [PATCH 24/24] Empty-Commit