Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 junit4 android
run: |
cd junit-5/android
gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk"
- name: Run gradle test for junit4 ios
run: |
cd junit-5/ios
gradle clean sampleTest
- name: Run gradle sample-local-test for junit4 ios
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Run gradle sample-local-test for junit4 ios
- 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
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maven and gradle should be downloaded alternatively right and presence of both is not required. Can we update th readme accordingly.

- 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 +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`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistency in instruction here

- Run `gradle clean sampleTest` to run in gradle enviroment.

### **Use Local testing for apps that access resources hosted in development or testing environments :**

Expand All @@ -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)

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') }}"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need empty line here

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")
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line

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') }}"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line

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")
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line

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') }}"
}
15 changes: 15 additions & 0 deletions junit-5/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")
}
}
}
}