Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions .github/workflows/sanity-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 junit5 android
run: |
cd junit-5/android
gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk"
- name: Run gradle test for junit5 ios
run: |
cd junit-5/ios
gradle clean sampleTest
- name: Run gradle sample-local-test for junit5 ios
run: |
cd junit-5/ios
gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.ipa"
- if: always()
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-completed
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ local.log
.idea
*/*/logs
*.iml
bstack_*
gradlew*
gradle
.gradle
build
reports
50 changes: 42 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ These code samples are currently based on:
- 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 (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/)

### Install the dependencies

To install the dependencies for JUnit4 tests, run :
Expand Down Expand Up @@ -69,11 +75,25 @@ 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`
- **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
```

- 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`
- **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 :**

Expand All @@ -83,15 +103,29 @@ Getting Started with Appium tests in Junit4 and Junit5 on BrowserStack couldn't
```
browserstackLocal: true
```
- Run `mvn test -P sample-local-test`
- **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
```

- 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).
- 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`
- **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)

Expand Down
50 changes: 50 additions & 0 deletions junit-4/android/build.gradle
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') }}"
}
15 changes: 15 additions & 0 deletions junit-4/android/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")
}
}
}
}
50 changes: 50 additions & 0 deletions junit-4/ios/build.gradle
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') }}"
}
15 changes: 15 additions & 0 deletions junit-4/ios/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")
}
}
}
}
51 changes: 51 additions & 0 deletions junit-5/android/build.gradle
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') }}"
}
15 changes: 15 additions & 0 deletions junit-5/android/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")
}
}
}
}
51 changes: 51 additions & 0 deletions junit-5/ios/build.gradle
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') }}"
}
Loading