Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ac26750
SDKAD-153 Added gradle config for JUnit5
Aug 23, 2024
d8cf483
SDKAD-153 Removed implementation 'com.browserstack:browserstack-local…
Aug 23, 2024
8773751
SDKAD-153 Removed dependencies that are not needed
Aug 23, 2024
75b4d6b
SDKAD-153 Made gradle config similar to TestNg config
Aug 23, 2024
1fc0bab
SDKAD-153 Updated gradle config
Aug 23, 2024
066f358
SDKAD-153 Updated gradle config in readme
Aug 23, 2024
9301ae2
SDKAD-153 Added gradle config for junit4
Aug 26, 2024
c07740e
SDKAD-153 Updated readme for gradle config for JUnit5
Aug 26, 2024
710f345
SDKAD-153 Added gradle test run to github workflow
Aug 30, 2024
6d784e9
SDKAD-153 Added gradle test run to github workflow
Aug 30, 2024
d26e7ac
SDKAD-153 Updated task name in readme
Aug 30, 2024
7192a4d
SDKAD-153 Updated task name in readme
Aug 30, 2024
0eb4c21
Added config for gradle plugin
Oct 8, 2024
41aa1cf
Added config for gradle plugin
Oct 8, 2024
b30cb0c
Updated readme to add gradle plugin for integration
Oct 8, 2024
49710a3
Updated readme to add gradle plugin for integration
Oct 8, 2024
515eb26
Merge remote-tracking branch 'origin/SDKAD-153-gradle_config_junit5'
Baaryan Jan 22, 2025
7e03b8e
add gradle in gitignore
Baaryan Jan 22, 2025
d352b8a
exclude java 8 for mac os latest
Baaryan Jan 22, 2025
d821c4a
Fix gradle-sdk plugin version for junit4
Baaryan Jan 22, 2025
e9f40cf
Fix gradle-sdk plugin version for junit5
Baaryan Jan 22, 2025
bd2b8d3
fix readme for new plugin for junit 4 and 5
Baaryan Jan 22, 2025
5597687
fix selenium java version for supporting java 8
Baaryan Jan 22, 2025
c6c9acf
fix readme to match existing structure
Baaryan Jan 22, 2025
0f88363
Empty-Commit
Baaryan Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/maven-workflow-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ local.log
*.png
*.txt
**/logs
bstack_*
gradlew*
gradle
23 changes: 21 additions & 2 deletions junit-4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,36 @@

![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 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)
Expand Down
43 changes: 43 additions & 0 deletions junit-4/build.gradle
Original file line number Diff line number Diff line change
@@ -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.*'
}
}
15 changes: 15 additions & 0 deletions junit-4/settings.gradle
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
}
22 changes: 20 additions & 2 deletions junit-5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,35 @@ Master branch contains **Selenium 4 - W3C protocol** samples, for **Selenium 3**
<a href="https://browserstack.com"><img src="https://avatars.githubusercontent.com/u/1119453?s=200&v=4" width="40" height="40"></a>
<a href="https://junit.org/junit5/"><img src="https://camo.githubusercontent.com/abbaedce4b226ea68b0fd43521472b0b146d5ed57956116f69752f43e7ddd7d8/68747470733a2f2f6a756e69742e6f72672f6a756e6974352f6173736574732f696d672f6a756e6974352d6c6f676f2e706e67" width="40" height="40" ></a>

## 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)
Expand Down
43 changes: 43 additions & 0 deletions junit-5/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
}
15 changes: 15 additions & 0 deletions junit-5/settings.gradle
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
}
Loading