Espresso API
BrowserStack provides support for the Espresso testing framework for Android. You can run your Espresso tests written in both Java and Kotlin.
In order to get started with Espresso you need to make use of our Espresso API to perform the following steps:
- Upload your app
- Upload your test-suite
- Execute your build
Once the build execution is completed, the Espresso build and sessions APIs can be used to view the execution details.
Apps
In order to test your native and hybrid apps on BrowserStack, you need to upload your Android apps and Espresso test-suite to BrowserStack using our REST API.
Upload an App
Request Parameters
POST Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/upload"
-
file* "string"
The path to the app file in your local system.
Eg/Users/Desktop/Appium/app-debug.apk
-
custom_id* "string"
Constant name for the uploaded app. You can upload multiple apps using the same custom id.
Response [application/json]
Sample Response
{
"app_url":"bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3",
"custom_id":"SampleApp",
"shareable_id":"steve/SampleApp"
}
-
app_url "string"
App url of the app uploaded on BrowserStack..
Egbs://9c6dcb5649a8280ca800075bfd8f151115bba6b3
-
custom_id "string"
Constant name for the uploaded app. You can upload multiple apps using the same custom id.
-
shareable_id "string"
ID which can be used by other users of your team. Eg
steve/SampleApp
-
app_details [hash]
▶ SHOW VALUESApp Details object returned in the response
steve/SampleApp
-
app_url "string"
App url of the app uploaded on BrowserStack..
Egbs://9c6dcb5649a8280ca800075bfd8f151115bba6b3
-
app_size "string"
App url of the app uploaded on BrowserStack..
Egbs://9c6dcb5649a8280ca800075bfd8f151115bba6b3
-
app_settings "[hash]"
▶ SHOW VALUESApp url of the app uploaded on BrowserStack..
-
app_url "string"
App url of the app uploaded on BrowserStack..
-
app_capabilities "[hash]"
▶ SHOW VALUESApp url of the app uploaded on BrowserStack..
-
app_url "string"
App url of the app uploaded on BrowserStack..
-
app_size "string"
App url of the app uploaded on BrowserStack..
-
app_type "string"
App url of the app uploaded on BrowserStack..
-
-
app_type "string"
App url of the app uploaded on BrowserStack..
-
-
My custom note here
My custom note here
My custom note here
My custom note here
Sample H4
Sample para content here. Code here to check it out
Sample H5
Sample para content here.
Sample H6
Sample para content here.
Sample Table 1
Key | Value |
---|---|
My app name | Awesome Description here |
My app name | Awesome Description here |
Sample Half Page Table 1
Key | Value |
---|---|
My app name | Awesome Description here |
My app name | Awesome Description here |
Sample Table 2 with no header class
Key | Value |
---|---|
My app name | Awesome Description here |
My app name | Awesome Description here |
- Unordered List items
- Notice the stlying
Builds
An Espresso build represents your test-suite execution on Browserstack. Once you upload your Android app and Espresso test-suite, you can use the Build REST API endpoints, to perform the following actions:
- Execute the build
- Get details about your build executions
- Delete an Espresso build
Execute your build
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
-d {"app": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3", "testSuite": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1","project" : "Espresso_Test" "devices": ["Samsung Galaxy S20-10.0","Google Pixel 3-9.0"]} \
-H "Content-Type: application/json"
Repsonse
{
"message": "Success",
"build_id": "5c5ab4338cec13aeb78f7a6977344556ac00bccd6"
}
The Build API allows you to start the Espresso test execution on BrowserStack. As part of the API request, you must specify the app you want to test, the test-suite that contains your Espresso test cases and device(s) list.
Sharding the test-suite
In order to speed up your Espresso test executions, you can also split and execute the test-suite in multiple shards using the shard object parameter in the build API. There are different strategies available for sharding the test-suite on BrowserStack:
- Shard tests using
package
,class
,annotation
orsize
strategy - Shard tests using package, class, annotation or size strategy along with `deviceSelection` value as `any`/`all`
- Shard tests using autoShard strategy To know more about how to split your test-suite using shards, refer to our documentation - /docs/espresso/shards
Request Parameters
POST Request
# Execute build
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
-d {
"app": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3",\
"testSuite": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1",\
"project" : "Espresso_Test",\
"devices": [\
"Samsung Galaxy S20-10.0",\
"Google Pixel 3-9.0"\
]\
} \
-H "Content-Type: application/json"
Get build summary
# Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY"
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/{build_id}"
# Response
{
"id": "5c5ab4338cec13aeb78f7a6977344556ac00bccd6",
"framework": "espresso",
"duration": 83,
"status": "failed",
"input_capabilities": {
"devices": [
"Samsung Galaxy S20-10.0",
"OnePlus 7-9.0",
"Google Pixel 3-9.0"
],
"project": "Espresso_Test",
"app": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3",
"testSuite": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1"
},
"start_time": "2020-06-04 07:43:49 UTC",
"app_details": {
"url": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3",
"bundle_id": "com.sample.browserstack.samplecalculator",
"version": "1.0",
"name": "app-debug.apk"
},
"test_suite_details": {
"url": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1",
"bundle_id": "com.sample.browserstack.samplecalculator.test",
"version": "",
"name": "app-debugTest.apk"
},
"devices": [
{
"device": "Samsung Galaxy S20",
"os": "android",
"os_version": "10.0",
"sharding": false,
"sessions": [
{
"id": "4fc55a08d7e33651d962ad676c7d6a0a08902702",
"status": "failed",
"start_time": "2020-06-04 07:44:07 +0000",
"duration": 62,
"testcases": {
"count": 9,
"status": {
"passed": 3,
"failed": 6,
"skipped": 0,
"timedout": 0,
"error": 0,
"running": 0,
"queued": 0
}
}
}]
},
{
"device": "OnePlus 7",
"os": "android",
"os_version": "9.0",
"sharding": false,
"sessions": [
{
"id": "1f5c3cb7d1f7560635f6c83eafe418a2fabbef0d",
"status": "failed",
"start_time": "2020-06-04 07:44:10 +0000",
"duration": 59,
"testcases": {
"count": 9,
"status": {
"passed": 3,
"failed": 6,
"skipped": 0,
"timedout": 0,
"error": 0,
"running": 0,
"queued": 0
}
}
}]
},
{
"device": "Google Pixel 3",
"os": "android",
"os_version": "9.0",
"sharding": false,
"sessions": [
{
"id": "a8760f7f5fd21f73673060d4047899e6a94d9e6",
"status": "failed",
"start_time": "2020-06-04 07:44:08 +0000",
"duration": 62,
"testcases": {
"count": 9,
"status": {
"passed": 3,
"failed": 6,
"skipped": 0,
"timedout": 0,
"error": 0,
"running": 0,
"queued": 0
}
}
}]
}
]
}
Request Parameters
Response Parameters
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.