Features

Espresso Testing

TestingBot provides access to Android physical devices and Android emulators, capable of running your Android Espresso tests.

Espresso is a mobile automation framework from Google, designed to run UI tests for Android applications.

Using Espresso in combination with TestingBot's Android cloud service is very straightforward:

  • Upload your native mobile Android app, together with the Espresso test apk file. These are created with either Java or Kotlin.
  • Specify on which devices you want to run the Espresso tests.
  • Retrieve the results of the Espresso tests.

Getting Started

To get started, please follow the steps below:

  1. You will need a key and secret to connect to the TestingBot grid.
    These credentials are available in the TestingBot member area.

  2. Espresso tests require a seperate apk file for testing. So you will need to upload both the app (.apk or .aab file) and the test file (.apk).

You can also use the TestingBot Espresso Demo App to give the Espresso Cloud Testing functionality a try.

Upload Android App

To run Android Espresso tests on TestingBot, you will first have to upload your .apk or .aab file to TestingBot Storage.

Copy code
curl -u api_key:api_secret \
-X POST "https://api.testingbot.com/v1/app-automate/espresso/app" \
-F "file=@/path/to/app/file/Application-debug.apk"

The API response will include an id response, which you can use in the other API calls.

Copy code
{
    "id": 4012
}

Upload Espresso Test Suite

You can now upload the .apk file containing the Espresso tests.
The upload process is similar to the app upload process.

Copy code
curl -u api_key:api_secret \
-X POST "https://api.testingbot.com/v1/app-automate/espresso/:id/tests" \
-F "file=@/path/to/app/file/Application-debug-test.apk"

Replace the :id with the identifier you received during the app upload call.

Specify devices

You can specify one or more Android device capabilities with your API call.
These capabilities can target either Android emulators, or physical Android devices.

1. Select a Device Type
2. Select a Device Name
Copy code

We offer special parameters which you can use to allocate a device:

Regex Input Result
"Pixel.*" This will allocate any available Pixel device (phone)
"*" This will allocate a random available Android device
"Samsung [20-21]" This will allocate either an Samsung 20 or 21

Some Examples:

Copy code
// find any Samsung Galaxy, except 23
-d '{"capabilities":[{"deviceName":"^(Galaxy.*)(?!23)$", "platformName":"Android", "realDevice": true}]}'

// find any device which name starts with Pixel
-d '{"capabilities":[{"deviceName":"Pixel.*", "platformName":"Android", "realDevice": true}]}'

Tablet Only

You can specify the tabletOnly capability when you only want to allocate a tablet device.

Phone Only

You can specify the phoneOnly capability when you only want to allocate a phone device.

Copy code

-d '{"capabilities":[{"deviceName":"*", "tabletOnly": true, "platformName":"Android", "realDevice": true}]}'

-d '{"capabilities":[{"deviceName":"*", "phoneOnly": true, "platformName":"Android", "realDevice": true}]}'

Run Espresso Tests

Now that you have uploaded both your Android application and the Espresso test suite, you can run your first Espresso test on the TestingBot cloud.

Copy code
curl -u api_key:api_secret \
-X POST "https://api.testingbot.com/v1/app-automate/espresso/:id/run" \
-d '{"capabilities":[{"platform":"ANDROID", "version":12, "deviceName":"Pixel 6", "platformName":"Android"}]}' \
-H "Content-Type: application/json"

Replace the :id with the identifier you received during the app upload call.

The API response will include a success response, indicating if the tests will start or if an error occurred.

Copy code
{
    "success": true
}

View Espresso Test Results

You will now see a test appear in the TestingBot dashboard, together with a video, test logs and other metadata.

Alternatively, you can query the TestingBot REST API to fetch the results of your Espresso tests:

Copy code
curl -u api_key:api_secret \
"https://api.testingbot.com/v1/app-automate/espresso/:id"

Replace the :id with the identifier you received during the app upload call.

The API response will include a response indicating the current state of the Espresso test results.

Copy code
{
  "runs": [
      {
          "status": "DONE",
          "capabilities": {
              "version": "12",
              "deviceName": "Pixel 6",
              "platformName": "Android"
          },
          "success": false,
          "test": {
              "sessionId": "30f6eild082c3-804f3c0ec2df-a18b2d431ffb-169920992163-48455547",
              "environment": {
                  "name": "chrome",
                  "os": "Pixel 6 - 12.0",
                  "version": "12.0"
              }
          }
      }
  ],
  "version": "1.0"
}