Espresso is a mobile automation framework from Google that helps you write UI tests for your Android applications. BrowserStack App Automate supports Espresso testing on a wide range of real Android devices. This guide will help you run your first Espresso test on BrowserStack.
You will need a BrowserStack username
and access key
. To obtain your access credentials, sign up for a free trial or purchase a plan.
Espresso tests are built into a separate apk
file from your app. Hence, you will need access to both the app (.apk
or .aab
file) as well as Espresso test-suite (separate .apk
file).
.apk
files and are looking to simply try App Automate, you can download our sample Calculator app and Calculator test-suite. Alternatively, refer to our Espresso sample GitHub repository.
Upload your Android app (.apk
or .aab
file) to BrowserStack servers using our REST API. Here is an example cURL
request to upload the app :
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/app" \
-F "file=@/path/to/app/file/Application-debug.apk"
A sample response for the above request is shown below:
{
"app_url":"bs://j3c874f21852ba57957a3fdc33f47514288c4ba4"
}
Note the value of app_url
returned in the response to above REST API request. This will be used later to specify the application under test for your Espresso test execution.
Upload your Espresso test-suite (.apk
file) to BrowserStack servers using our REST API. Here is an example cURL
request to upload the test-suite :
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/test-suite" \
-F "file=@/path/to/app/file/Application-debug-test.apk"
A sample response for the above request is shown below:
{
"test_url":"bs://f7c874f21852ba57957a3fdc33f47514288c4ba4"
}
Note the value of test_url
returned in the response to above REST API request. This will be used later to specify the test-suite containing Espresso test cases for your test execution.
Once the app and test-suite are uploaded to BrowserStack servers, you are ready to run your first Espresso test on BrowserStack. Use the REST API to start the test execution as shown in the example cURL
request below :
An example response to the above request is shown below. Note that the build_id
is used to uniquely identify your test execution.
{
"message" : "Success",
"build_id" : "4d2b4deb810af077d5aed98f479bfdd2e64f36c3"
}
Once you start an Espresso test execution using REST API, you will be able to access the test execution results on the App Automate dashboard as well as using our REST API. You can access overall summary of your test execution and also check the result and debugging logs for every test case in the Espresso test-suite.
Contact our Support team for immediate help while we work on improving our docs.
Contact our Support team for immediate help while we work on improving our docs.
Thank you for your valuable feedback!