Skip to content

Commit f90f396

Browse files
Merge pull request #1 from kn-neeraj/testng_code_samples_minor_updates
Testng code samples minor updates
2 parents 7281807 + 29b95e7 commit f90f396

File tree

13 files changed

+24
-62
lines changed

13 files changed

+24
-62
lines changed

README.md

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# testng-appium-app-browserstack
22

3-
[TestNG](http://testng.org) Integration with BrowserStack.
3+
This repository demonstrates how to run Appium tests in [TestNG](http://testng.org) on BrowserStack App Automate.
44

55
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
66

7+
## Setup
8+
79
### Requirements
810

911
1. Java 8+
@@ -33,76 +35,24 @@ cd ios/testng-examples
3335
mvn clean
3436
```
3537

36-
### Update `username` and `access_key` keys in *.conf.json
37-
38-
- Update *.conf.json files for `username`, `access_key` keys inside the [android/testng-examples/src/test/resources/](android/testng-examples/src/test/resources) for Android examples and inside [ios/testng-examples/src/test/resources](ios/testng-examples/src/test/resources) for iOS examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings).
39-
40-
- Note: You can also export the environment variables for the Username and Access Key of your BrowserStack account.
41-
42-
```
43-
export BROWSERSTACK_USERNAME=<browserstack-username> &&
44-
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
45-
```
46-
47-
### Upload app and update `app` key in *.conf.json
48-
49-
- Android
50-
- Upload your Native App (.apk or .aab file) to BrowserStack servers using upload API:
51-
52-
```
53-
curl -u "username:access_key" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@/path/to/app/file/Application-debug.apk"
54-
```
55-
- If you do not have an .apk file and looking to simply try App Automate, [you can download our sample app and upload](https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk)
56-
to the BrowserStack servers using the above API.
57-
58-
- You can use public url as well to upload your app
59-
60-
```
61-
curl -u "username:access_key" \
62-
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
63-
-F "url=https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk"
64-
```
65-
- Please note the value of app_url in the API response (bs://f7c874f21852.... in the above examples).
66-
67-
- Update *.conf.json with value of `app_url`(got from response) for `app` key
68-
69-
- Files inside the [android/testng-examples/src/test/resources/](android/testng-examples/src/test/resources) for Android examples and inside [ios/testng-examples/src/test/resources](ios/testng-examples/src/test/resources) for iOS examples.
70-
71-
7238
## Getting Started
7339

7440
Getting Started with Appium tests in TestNg on BrowserStack couldn't be easier!
7541

7642
### **Run first test :**
7743

7844
- Switch to `run_first_test` directory under [Android examples](android/testng-examples) or [iOS examples](ios/testng-examples)
79-
- Then run
80-
```sh
81-
mvn test -P first
82-
```
83-
- Alternatively, you can follow the steps outlined in the documentation - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng)
45+
- Follow the steps outlined in the documentation - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng)
8446

8547
### **Speed up test execution with parallel testing :**
8648

8749
- Switch to `run_parallel_test` directory under [Android examples](android/testng-examples/) or [iOS examples](ios/testng-examples/)
88-
- Then run
89-
```sh
90-
mvn test -P parallel
91-
```
92-
93-
- Alternatively, you can follow the steps outlined in the documentation - [Get Started with your parallel test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng/parallelize-tests)
50+
- Follow the steps outlined in the documentation - [Get Started with parallel testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng/parallelize-tests)
9451

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

97-
- If you do not have an local .apk file and looking to simply try local for App Automate, [you can download our sample local app and upload](https://www.browserstack.com/app-automate/sample-apps/android/LocalSample.apk)
98-
to the BrowserStack servers using the same app upload API.
99-
10054
- Switch to `run_local_test` directory under [Android examples](android/testng-examples/) or [iOS examples](ios/testng-examples/)
101-
- Then run
102-
```sh
103-
mvn test -P local
104-
```
105-
- Alternatively, you can follow the steps outlined in the documentation - [Get Started with Local testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng/local-testing)
55+
- Follow the steps outlined in the documentation - [Get Started with Local testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng/local-testing)
10656

10757
**Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help)
10858

android/testng-examples/src/test/java/com/browserstack/run_first_test/BrowserStackTestNGTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public void setUp() throws Exception {
6464

6565
@AfterMethod(alwaysRun=true)
6666
public void tearDown() throws Exception {
67+
// Invoke driver.quit() to indicate that the test is completed.
68+
// Otherwise, it will appear as timed out on BrowserStack.
6769
driver.quit();
6870
}
6971
}

android/testng-examples/src/test/java/com/browserstack/run_local_test/BrowserStackTestNGTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public void setUp() throws Exception {
7474

7575
@AfterMethod(alwaysRun=true)
7676
public void tearDown() throws Exception {
77+
// Invoke driver.quit() to indicate that the test is completed.
78+
// Otherwise, it will appear as timed out on BrowserStack.
7779
driver.quit();
7880
if(local != null) local.stop();
7981
}

android/testng-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackTestNGTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public void setUp(String deviceIndex) throws Exception {
6666

6767
@AfterMethod(alwaysRun=true)
6868
public void tearDown() throws Exception {
69+
// Invoke driver.quit() to indicate that the test is completed.
70+
// Otherwise, it will appear as timed out on BrowserStack.
6971
driver.quit();
7072
}
7173
}

android/testng-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "TestNg Android First",
99
"name": "first_test",
1010
"browserstack.debug": true,
11-
"app": "bs://<hashed app-id>"
11+
"app": "bs://<app-id>"
1212
},
1313

1414
"environments": [

android/testng-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "local_test",
1010
"browserstack.debug": true,
1111
"browserstack.local": true,
12-
"app": "bs://<hashed app-id>"
12+
"app": "bs://<app-id>"
1313
},
1414

1515
"environments": [

android/testng-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "TestNg Android Parallel",
99
"name": "parallel_test",
1010
"browserstack.debug": true,
11-
"app": "bs://<hashed app-id>"
11+
"app": "bs://<app-id>"
1212
},
1313

1414
"environments": [

ios/testng-examples/src/test/java/com/browserstack/run_first_test/BrowserStackTestNGTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public void setUp() throws Exception {
6565

6666
@AfterMethod(alwaysRun=true)
6767
public void tearDown() throws Exception {
68+
// Invoke driver.quit() to indicate that the test is completed.
69+
// Otherwise, it will appear as timed out on BrowserStack.
6870
driver.quit();
6971
}
7072
}

ios/testng-examples/src/test/java/com/browserstack/run_local_test/BrowserStackTestNGTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public void setUp() throws Exception {
7474

7575
@AfterMethod(alwaysRun=true)
7676
public void tearDown() throws Exception {
77+
// Invoke driver.quit() to indicate that the test is completed.
78+
// Otherwise, it will appear as timed out on BrowserStack.
7779
driver.quit();
7880
if(local != null) local.stop();
7981
}

ios/testng-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackTestNGTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public void setUp(String deviceIndex) throws Exception {
6666

6767
@AfterMethod(alwaysRun=true)
6868
public void tearDown() throws Exception {
69+
// Invoke driver.quit() to indicate that the test is completed.
70+
// Otherwise, it will appear as timed out on BrowserStack.
6971
driver.quit();
7072
}
7173
}

ios/testng-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "TestNg iOS First",
99
"name": "first_test",
1010
"browserstack.debug": true,
11-
"app": "bs://<hashed app-id>"
11+
"app": "bs://<app-id>"
1212
},
1313

1414
"environments": [

ios/testng-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "local_test",
1010
"browserstack.debug": true,
1111
"browserstack.local": true,
12-
"app": "bs://<hashed app-id>"
12+
"app": "bs://<app-id>"
1313
},
1414

1515
"environments": [

ios/testng-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "TestNg iOS Parallel",
99
"name": "parallel_test",
1010
"browserstack.debug": true,
11-
"app": "bs://<hashed app-id>"
11+
"app": "bs://<app-id>"
1212
},
1313

1414
"environments": [

0 commit comments

Comments
 (0)