-
Notifications
You must be signed in to change notification settings - Fork 22
Added Gradle config support for JUnit 4 & 5 #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -72,6 +72,22 @@ jobs: | |||||
| cd junit-4/ios | ||||||
| mvn compile | ||||||
| mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.ipa" | ||||||
| - name: Run gradle test for junit4 android | ||||||
| run: | | ||||||
| cd junit-4/android | ||||||
| gradle clean sampleTest | ||||||
| - name: Run gradle sample-local-test for junit4 android | ||||||
| run: | | ||||||
| cd junit-4/android | ||||||
| gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk" | ||||||
| - name: Run gradle test for junit4 ios | ||||||
| run: | | ||||||
| cd junit-4/ios | ||||||
| gradle clean sampleTest | ||||||
| - name: Run gradle sample-local-test for junit4 ios | ||||||
| run: | | ||||||
| cd junit-4/ios | ||||||
| gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.ipa" | ||||||
| - name: Run mvn test for junit5 android | ||||||
| run: | | ||||||
| cd junit-5/android | ||||||
|
|
@@ -92,6 +108,22 @@ jobs: | |||||
| cd junit-5/ios | ||||||
| mvn compile | ||||||
| mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.ipa" | ||||||
| - name: Run gradle test for junit5 android | ||||||
| run: | | ||||||
| cd junit-5/android | ||||||
| gradle clean sampleTest | ||||||
| - name: Run gradle sample-local-test for junit4 android | ||||||
rhisav-25 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| run: | | ||||||
| cd junit-5/android | ||||||
| gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk" | ||||||
| - name: Run gradle test for junit4 ios | ||||||
rhisav-25 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| run: | | ||||||
| cd junit-5/ios | ||||||
| gradle clean sampleTest | ||||||
| - name: Run gradle sample-local-test for junit4 ios | ||||||
|
||||||
| - name: Run gradle sample-local-test for junit4 ios | |
| - name: Run gradle sample-local-test for junit5 ios |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,9 @@ local.log | |
| .idea | ||
| */*/logs | ||
| *.iml | ||
| bstack_* | ||
| gradlew* | ||
| gradle | ||
| .gradle | ||
| build | ||
| reports | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,10 @@ These code samples are currently based on: | |
| - 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 JUnit4 tests, run : | ||
|
|
@@ -69,11 +73,13 @@ Getting Started with Appium tests in Junit4 and Junit5 on BrowserStack couldn't | |
|
|
||
| - Junit4 | ||
| - Update `browserstack.yml` file at root level of [Android Junit4 examples](junit-4/android) or [iOS Junit4 examples](junit-4/ios) with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings) | ||
| - Run `mvn test -P sample-test` | ||
| - Run `mvn test -P sample-test` to run in maven enviroment. | ||
| - Run `gradle clean sampleTest` to run in gradle enviroment. | ||
|
|
||
| - Junit5 | ||
| - Update `browserstack.yml` file at root level of [Android Junit5 examples](junit-5/android) or [iOS Junit5 examples](junit-5/ios) with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings) | ||
| - Run `mvn test -P sample-test` | ||
|
||
| - Run `gradle clean sampleTest` to run in gradle enviroment. | ||
|
|
||
| ### **Use Local testing for apps that access resources hosted in development or testing environments :** | ||
|
|
||
|
|
@@ -83,15 +89,17 @@ Getting Started with Appium tests in Junit4 and Junit5 on BrowserStack couldn't | |
| ``` | ||
| browserstackLocal: true | ||
| ``` | ||
| - Run `mvn test -P sample-local-test` | ||
| - Run `mvn test -P sample-local-test` to run in maven enviroment. | ||
| - Run `gradle clean sampleLocalTest` to run in gradle enviroment. | ||
|
|
||
| - Junit5 | ||
| - Update `browserstack.yml` file at root level of Android Junit5 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings) | ||
| - Simply configure the browserstackLocal parameter in the browserstack.yml file accordingly in [Android Junit5 examples](junit-5/android) or [iOS Junit5 examples](junit-5/ios). | ||
| ``` | ||
| browserstackLocal: true | ||
| ``` | ||
| - Run `mvn test -P sample-local-test` | ||
| - Run `mvn test -P sample-local-test` to run in maven enviroment. | ||
| - Run `gradle clean sampleLocalTest` to run in gradle enviroment. | ||
|
|
||
| **Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| plugins { | ||
| id 'java' | ||
| id 'com.browserstack.gradle-sdk' version "1.1.2" | ||
| } | ||
|
|
||
| repositories { mavenCentral() } | ||
|
|
||
| dependencies { | ||
| testImplementation 'junit:junit:4.13.2' | ||
| implementation 'commons-io:commons-io:2.11.0' | ||
| implementation 'org.seleniumhq.selenium:selenium-java:4.4.0' | ||
| implementation 'io.appium:java-client:8.1.1' | ||
| implementation 'com.googlecode.json-simple:json-simple:1.1.1' | ||
| 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) { | ||
| dependsOn cleanTest | ||
| useJUnit() | ||
|
|
||
| include 'com/browserstack/FirstTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } | ||
|
|
||
|
|
||
| task sampleLocalTest(type: Test) { | ||
| dependsOn cleanTest | ||
| useJUnit() | ||
|
|
||
| include 'com/browserstack/LocalTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } | ||
|
||
| 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") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| plugins { | ||
| id 'java' | ||
| id 'com.browserstack.gradle-sdk' version "1.1.2" | ||
| } | ||
|
|
||
| repositories { mavenCentral() } | ||
|
|
||
| dependencies { | ||
| testImplementation 'junit:junit:4.13.2' | ||
| implementation 'commons-io:commons-io:2.11.0' | ||
| implementation 'org.seleniumhq.selenium:selenium-java:4.4.0' | ||
| implementation 'io.appium:java-client:8.1.1' | ||
| implementation 'com.googlecode.json-simple:json-simple:1.1.1' | ||
| 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) { | ||
| dependsOn cleanTest | ||
| useJUnit() | ||
|
|
||
| include 'com/browserstack/FirstTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } | ||
|
|
||
|
|
||
| task sampleLocalTest(type: Test) { | ||
| dependsOn cleanTest | ||
| useJUnit() | ||
|
|
||
| include 'com/browserstack/LocalTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } | ||
|
||
| 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") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| plugins { | ||
| id 'java' | ||
| id 'com.browserstack.gradle-sdk' version "1.1.2" | ||
| } | ||
|
|
||
| repositories { mavenCentral() } | ||
|
|
||
| dependencies { | ||
| testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0' | ||
| testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0' | ||
| implementation 'commons-io:commons-io:2.11.0' | ||
| implementation 'org.seleniumhq.selenium:selenium-java:4.4.0' | ||
| implementation 'io.appium:java-client:8.1.1' | ||
| implementation 'com.googlecode.json-simple:json-simple:1.1.1' | ||
| 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) { | ||
| dependsOn cleanTest | ||
| useJUnitPlatform() | ||
|
|
||
| include 'com/browserstack/FirstTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } | ||
|
|
||
|
|
||
| task sampleLocalTest(type: Test) { | ||
| dependsOn cleanTest | ||
| useJUnitPlatform() | ||
|
|
||
| include 'com/browserstack/LocalTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } |
| 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") | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| plugins { | ||
| id 'java' | ||
| id 'com.browserstack.gradle-sdk' version "1.1.2" | ||
| } | ||
|
|
||
| repositories { mavenCentral() } | ||
|
|
||
| dependencies { | ||
| testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0' | ||
| testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0' | ||
| implementation 'commons-io:commons-io:2.11.0' | ||
| implementation 'org.seleniumhq.selenium:selenium-java:4.4.0' | ||
| implementation 'io.appium:java-client:8.1.1' | ||
| implementation 'com.googlecode.json-simple:json-simple:1.1.1' | ||
| 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) { | ||
| dependsOn cleanTest | ||
| useJUnitPlatform() | ||
|
|
||
| include 'com/browserstack/FirstTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } | ||
|
|
||
|
|
||
| task sampleLocalTest(type: Test) { | ||
| dependsOn cleanTest | ||
| useJUnitPlatform() | ||
|
|
||
| include 'com/browserstack/LocalTest*' | ||
|
|
||
| jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}" | ||
| } |
| 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") | ||
| } | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.