Features

Filter Espresso Test Cases

By default, TestingBot will execute all tests present in the Espresso .apk.

The Espresso test runner (which is usually AndroidJUnitRunner) provides multiple options to filter test cases for execution.

You might want to use these filter options for specific use cases, such as:

  • Run only specific tests for a bugfix.
  • Only run a subset of tests, for quick smoke testing. Instead of waiting on all your Espresso tests.
  • Run specific tests for specific environments (production, staging, ...)

Below you'll find the different filter options that TestingBot and Espresso provide.

  • class: will run all tests in a specific class
  • notClass: will run all tests except the tests in a particular class
  • size: will run a specific test size annotated with SmallTest, MediumTest or LargeTest
  • package: will run all tests in a specific Java package
  • notPackage: will run all tests except the tests in a specific package
  • annotation: will run all tests with a specific annotation
  • notAnnotation: will run all tests except the tests with a specific annotation
  • numShards: filter test run to a shard of all tests, where numShards is an integer greater than 0 and shardIndex is an integer between 0 (inclusive) and numShards

class Filter

To only run Espresso tests for a specific class, you can use the class option.

You can pass a list of fully qualified Java class names. See the example below.

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

This call with start an Espresso test Session on the specific device and only run the Espresso tests for the classNames specified.

notClass Filter

Use the notClass option to run all Espresso tests except for the tests in the classes specified with this option.

You can pass a list of fully qualified Java class names. See the example below.

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

size Filter

The size option allows you to specify which tests you want to run, depending on the annotated size: SmallTest, MediumTest or LargeTest

You can pass an array of sizes, see below for an example.

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

package Filter

The package filter allows you to specify for which package the Espresso tests should run.

You can pass an array of packages, see below for an example.

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

notPackage Filter

The notPackage filter allows you to indicate that Espresso tests should run for everything except for the packages defined.

You can pass an array of packages, see below for an example.

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

annotation Filter

The annotation filter will run tests annotated with the field (or fields) you specified.

You can pass an array of annotations, see below for an example.

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

notAnnotation Filter

The notAnnotation filter will run all tests except those annotated with the field (or fields) you specified.

You can pass an array of notAnnotations, see below for an example.

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