diff --git a/.github/workflows/maven-workflow-run.yml b/.github/workflows/maven-workflow-run.yml
index 7c9a66c..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 }}
@@ -67,6 +70,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
@@ -82,6 +93,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/.gitignore b/.gitignore
index 87f8a89..272a376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,6 @@ local.log
*.png
*.txt
**/logs
+bstack_*
+gradlew*
+gradle
diff --git a/junit-4/README.md b/junit-4/README.md
index 856f86c..4aa029c 100644
--- a/junit-4/README.md
+++ b/junit-4/README.md
@@ -5,17 +5,36 @@

-## 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 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)
+
+
## 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..fce6feb
--- /dev/null
+++ b/junit-4/build.gradle
@@ -0,0 +1,43 @@
+plugins {
+ id 'java'
+ id 'com.browserstack.gradle-sdk' version "1.1.2" // sdk plugin
+}
+
+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 sampleTest(type: Test) {
+ useJUnit() {
+ dependsOn cleanTest
+ include '**/*BStackSampleTest.*'
+ }
+}
+
+task sampleLocalTest(type: Test) {
+ useJUnit() {
+ dependsOn cleanTest
+ include '**/*BStackLocalTest.*'
+ }
+}
diff --git a/junit-4/settings.gradle b/junit-4/settings.gradle
new file mode 100644
index 0000000..3e5b662
--- /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.1.2")
+ }
+ }
+ }
+}
diff --git a/junit-5/README.md b/junit-5/README.md
index bd917a0..bb68ee5 100644
--- a/junit-5/README.md
+++ b/junit-5/README.md
@@ -4,17 +4,35 @@ 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 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)
+
+
## 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-5/build.gradle b/junit-5/build.gradle
new file mode 100644
index 0000000..966f5ed
--- /dev/null
+++ b/junit-5/build.gradle
@@ -0,0 +1,43 @@
+plugins {
+ id 'java'
+ id 'com.browserstack.gradle-sdk' version "1.1.2" // sdk plugin
+}
+
+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.1.4'
+ 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).configureEach { task ->
+ browserstackSDKArtifact?.file?.with {
+ task.systemProperties = System.properties
+ task.jvmArgs += "-javaagent:$it"
+ }
+}
+
+task sampleTest(type: Test) {
+ dependsOn cleanTest
+ include '**/*BStackSampleTest.*'
+ useJUnitPlatform()
+}
+
+task sampleLocalTest(type: Test) {
+ dependsOn cleanTest
+ include '**/*BStackLocalTest.*'
+ useJUnitPlatform()
+}
diff --git a/junit-5/settings.gradle b/junit-5/settings.gradle
new file mode 100644
index 0000000..3e5b662
--- /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.1.2")
+ }
+ }
+ }
+}