You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Now you can run your Espresso framework on LambdaTest and this particular feature allows users to pass and retrieve environment variables (like STAGE, PROD, or DEV) during automated Android tests.
6
6
keywords:
@@ -48,35 +48,35 @@ import TabItem from '@theme/TabItem';
48
48
}}
49
49
></script>
50
50
51
-
Espresso is a powerful UI testing framework for Android that allows you to write automated UI tests for Android apps. When testing your Android apps on LambdaTest, you may need to pass environment variables for various configurations (e.g., STAGE, PROD, DEV) to manage different environments seamlessly.
51
+
This feature allows you to dynamically set and test environment variables during Espresso test execution on LambdaTest.
52
52
53
-
This guide will walk you through setting up, accessing, and using environment variables for Espresso tests on LambdaTest. You'll learn how to define and retrieve these variables using different configuration formats (JSON, YAML), integrate them with LambdaTest, and run your tests smoothly.
53
+
## Step 1: Create Variables in Your Test Suite
54
+
Define environment variables in your Espresso test suite to fetch the variable values during execution.
54
55
55
-
## Prerequisites
56
56
57
-
- Your LambdaTest [Username and Access key](https://accounts.lambdatest.com/security).
58
-
- Access to an **Android** app (.apk) and an **Espresso Test** app (.apk file).
59
-
60
-
:::tip
61
-
62
-
If you do not have any **Android** app (.apk) and an **Espresso Test** app (.apk) file, you can run your sample tests on LambdaTest by using our sample :link:[Android app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk) and a sample :link:[Espresso Test](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android_expressotest.apk).
Now, you need to export your environment variables *LT_USERNAME* and *LT_ACCESS_KEY* that are available in the [LambdaTest Profile page](https://accounts.lambdatest.com/detail/profile).
68
+
To begin testing, upload your Android application (.apk file) to LambdaTest's servers. You'll use our **REST API** for this process.
69
69
70
-
Run the below mentioned commands in your terminal to setup the CLI and the environment variables.
70
+
-**Authentication :** You'll need your LambdaTest Username and AccessKey. Combine them in the format `Username:AccessKey`.
71
+
-**Uploading the App :** Use **cURL command** to send a request to our API. The request should include the path to your application file (**appFile**).
- Provide the path of your android application in the above URL in place of `<PATH_OF_YOUR_ANDROID_APP>`
98
+
- Response of above cURL will be a **JSON** object containing the `App URL` of the format - `lt://APP123456789123456789` and will be used in the last step.
99
+
:::
98
100
99
-
### Upload your App
101
+
##Step 3: Upload Your Test Suite
100
102
101
-
Upload your **android** application (.apk file) to the LambdaTest servers using our **REST API**. You need to provide your **Username** and **AccessKey** in the format ```Username:AccessKey``` in the **cURL** command for authentication. Make sure to add the path of the **appFile** in the cURL request.
103
+
Upload your Espresso test suite (.apk) file to LambdaTest servers using our REST API.
102
104
103
-
Here is an example cURL request to upload your app using our REST API:
105
+
The following sample cURL command shows how to upload a test suite:
Response of above cURL will be a **JSON** object containing the `App URL` of the format - `APP123456789123456789` and will be used in the last step as `appId`.
130
+
:::info
131
+
- Provide the path of your android application in the above URL in place of `<PATH_OF_YOUR_TEST_SUITE_APP>`
132
+
- Response of above cURL will be a **JSON** object containing the `App URL` of the format - `lt://APP123456789123456789` and will be used in the last step.
133
133
:::
134
134
135
-
### Upload your Test Suite
136
-
137
-
Upload your **test suite** (.apk file) to the LambdaTest servers using our **REST API**. You need to provide your **Username** and **AccessKey** in the format `Username:AccessKey` in the **cURL** command for authentication. Make sure to add the path of the **appFile** in the cURL request. Here is an example cURL request to upload your app using our REST API:
- You will need **base64 encoded authentication** in order to execute your Espresso automation test suite. Enter your `username:accesskey` in **[Basic Authentication Header Generator](https://mixedanalytics.com/knowledge-base/api-connector-encode-credentials-to-base-64/)** to generate your auth token.
153
138
154
-
<TabItemvalue="powershell"label="Windows"default>
139
+
Take note of the base64 encoded authentication which needs to be added in the next step.
- Once you have uploaded your app and test suite, you can execute your test by running the following command:
148
+
149
+
> Enter your **BASIC_AUTH_TOKEN**, **APP_ID** (generated in the first step) and **TEST_SUITE_ID** (generated in the second step) in the below command.
166
150
167
-
Response of above cURL will be a **JSON** object containing the `App URL` of the format - `APP123456789123456789` and will be used in the next step as ``testSuiteAppId``
168
-
169
-
:::
151
+
```bash
152
+
curl --location --request POST 'https://mobile-api.lambdatest.com/framework/v1/espresso/build' \
To generate artifacts for your XCUI tests, add the `artifacts: true` and `report: true` flag in your YAML file:
208
-
209
-
```yaml
210
-
report: true
211
-
212
-
framework:
213
-
name: "android/espresso"
214
-
args:
215
-
artifacts: true
216
-
...//
217
-
```
218
-
219
-
To download these artifacts in your local machine, you can pass the `--download-artifacts` and `--download-report` flag with the CLI command to execute the tests as shown in the next step.
220
-
221
-
## Step 5: Execute your Test Suite
222
-
223
-
> **NOTE :** In case of macOS, if you get a permission denied warning while executing CLI, simply run **`chmod u+x ./hyperexecute`** to allow permission. In case you get a security popup, allow it from your **System Preferences** → **Security & Privacy** → **General tab**.
224
-
225
-
Run the below command in your terminal at the root folder of the project:
0 commit comments