|
1 | 1 | # junit-appium-app-browserstack |
2 | | -[JUnit4](http://junit.org/junit4/) and [Junit5](https://junit.org/junit5/) Integration with BrowserStack. |
3 | 2 |
|
4 | | - |
| 3 | +This repository demonstrates how to run Appium tests in [JUnit4](http://junit.org/junit4/) and [Junit5](https://junit.org/junit5/) on BrowserStack App Automate. |
5 | 4 |
|
6 | | - |
| 5 | + |
7 | 6 |
|
8 | 7 | ## Setup |
9 | 8 |
|
|
17 | 16 |
|
18 | 17 | 2. Maven |
19 | 18 | - If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi) |
20 | | - - For installation, follow the instructions [here]((https://maven.apache.org/install.html)) |
| 19 | + - For installation, follow the instructions [here](https://maven.apache.org/install.html) |
| 20 | + |
21 | 21 | ### Install the dependencies |
22 | 22 |
|
23 | 23 | To install the dependencies for Android tests, run : |
@@ -54,109 +54,39 @@ To install the dependencies for iOS tests, run : |
54 | 54 | mvn clean |
55 | 55 | ``` |
56 | 56 |
|
57 | | -### Update `username` and `access_key` keys in *.conf.json |
58 | | - |
59 | | -- Junit4 |
60 | | - |
61 | | - - Update *.conf.json files for `username`, `access_key` keys inside the [android/junit4-examples/src/test/resources/](android/junit4-examples/src/test/resources) for Android examples and inside [ios/junit4-examples/src/test/resources](ios/junit4-examples/src/test/resources) for iOS examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings). |
62 | | - |
63 | | -- Junit5 |
64 | | - |
65 | | - - Update *.conf.json files for `username`, `access_key` inside the [android/junit5-examples/src/test/resources](android/junit5-examples/src/test/resources) for Android examples and inside [ios/junit5-examples/src/test/resources](ios/junit5-examples/src/test/resources) for iOS examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings). |
66 | | - |
67 | | -- Note: You can also export the environment variables for the Username and Access Key of your BrowserStack account. |
68 | | - |
69 | | - ``` |
70 | | - export BROWSERSTACK_USERNAME=<browserstack-username> && |
71 | | - export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key> |
72 | | - ``` |
73 | | - |
74 | | -### Upload app and update `app` key in *.conf.json |
75 | | - |
76 | | -- Android |
77 | | - - Upload your Native App (.apk file) to BrowserStack servers using upload API: |
78 | | - |
79 | | - ``` |
80 | | - curl -u "username:access_key" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@/path/to/app/file/Application-debug.apk" |
81 | | - ``` |
82 | | - - 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) |
83 | | - to the BrowserStack servers using the above API. |
84 | | - |
85 | | - - You can use public url as well to upload your app |
86 | | - |
87 | | - ``` |
88 | | - curl -u "username:access_key" \ |
89 | | - -X POST "https://api-cloud.browserstack.com/app-automate/upload" \ |
90 | | - -F "url=https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk" |
91 | | - ``` |
92 | | - - Please note the value of app_url in the API response (bs://f7c874f21852.... in the above examples). |
93 | | - |
94 | | - - Update *.conf.json with value of `app_url`(got from response) for `app` key |
95 | | - |
96 | | - - Junit4 |
97 | | - |
98 | | - - Files inside the [android/junit4-examples/src/test/resources/](android/junit4-examples/src/test/resources) for Android examples and inside [ios/junit4-examples/src/test/resources](ios/junit4-examples/src/test/resources) for iOS examples. |
99 | | - |
100 | | - - Junit5 |
101 | | - |
102 | | - - Files inside the [android/junit5-examples/src/test/resources](android/junit5-examples/src/test/resources) for Android examples and inside [ios/junit5-examples/src/test/resources](ios/junit5-examples/src/test/resources) for iOS examples . |
103 | | - |
104 | | - |
105 | 57 | ## Getting Started |
106 | 58 |
|
107 | 59 | Getting Started with Appium tests in Junit4 and Junit5 on BrowserStack couldn't be easier! |
108 | 60 |
|
109 | 61 | ### **Run first test :** |
110 | 62 |
|
111 | 63 | - Junit4 |
112 | | - - Switch to `run_first_test` directory under [Android examples](android/junit4-examples) or [iOS examples](ios/junit4-examples) |
113 | | - - Then run |
114 | | - ```sh |
115 | | - mvn test -P first |
116 | | - ``` |
| 64 | + - Switch to `run_first_test` directory under [Android Junit4 examples](android/junit4-examples) or [iOS Junit4 examples](ios/junit4-examples) |
| 65 | + - 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/junit) |
| 66 | +
|
117 | 67 | - Junit5 |
118 | | - - Switch to `run_first_test` directory under [Android examples](android/junit5-examples) or [iOS examples](ios/junit5-examples) |
119 | | - - Then run |
120 | | - ```sh |
121 | | - mvn test -P first |
122 | | - ``` |
123 | | -- 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/junit) |
| 68 | + - Switch to `run_first_test` directory under [Android Junit5 examples](android/junit5-examples) or [iOS Junit5 examples](ios/junit5-examples) |
| 69 | + - 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/junit) |
124 | 70 |
|
125 | 71 | ### **Speed up test execution with parallel testing :** |
126 | 72 |
|
127 | 73 | - Junit4 |
128 | | - - Switch to `run_parallel_test` directory under [Android examples](android/junit4-examples/) or [iOS examples](ios/junit4-examples/) |
129 | | - - Then run |
130 | | - ```sh |
131 | | - mvn test -P parallel |
132 | | - ``` |
| 74 | + - Switch to `run_parallel_test` directory under [Android Junit4 examples](android/junit4-examples/) or [iOS Junit4 examples](ios/junit4-examples/) |
| 75 | + - 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/junit/parallelize-tests) |
| 76 | + |
133 | 77 | - Junit5 |
134 | | - - Switch to `run_parallel_test` directory under [Android examples](android/junit5-examples/) or [iOS examples](ios/junit5-examples/) |
135 | | - - Then run |
136 | | - ```sh |
137 | | - mvn test -P parallel |
138 | | - ``` |
139 | | - |
140 | | -- 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/junit/parallelize-tests) |
| 78 | + - Switch to `run_parallel_test` directory under [Android Junit5 examples](android/junit5-examples/) or [iOS Junit5 examples](ios/junit5-examples/) |
| 79 | + - 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/junit/parallelize-tests) |
141 | 80 |
|
142 | 81 | ### **Use Local testing for apps that access resources hosted in development or testing environments :** |
143 | 82 |
|
144 | | -- 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) |
145 | | - to the BrowserStack servers using the same app upload API. |
146 | | - |
147 | 83 | - Junit4 |
148 | | - - Switch to `run_local_test` directory under [Android examples](android/junit4-examples/) or [iOS examples](ios/junit4-examples/) |
149 | | - - Then run |
150 | | - ```sh |
151 | | - mvn test -P local |
152 | | - ``` |
| 84 | + - Switch to `run_local_test` directory under [Android Junit4 examples](android/junit4-examples/) or [iOS Junit4 examples](ios/junit4-examples/) |
| 85 | + - 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/junit/local-testing) |
| 86 | +
|
153 | 87 | - Junit5 |
154 | | - - Switch to `run_local_test` directory under [Android examples](android/junit5-examples/) or [iOS examples](ios/junit5-examples/) |
155 | | - - Then run |
156 | | - ```sh |
157 | | - mvn test -P local |
158 | | - ``` |
159 | | -- 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/junit/local-testing) |
| 88 | + - Switch to `run_local_test` directory under [Android Junit5 examples](android/junit5-examples/) or [iOS Junit5 examples](ios/junit5-examples/) |
| 89 | + - 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/junit/local-testing) |
160 | 90 |
|
161 | 91 | **Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help) |
162 | 92 |
|
|
0 commit comments