Preparing Espresso Tests for Upload

This document provides instructions for preparing Espresso tests for upload to Test. For guidance on authoring Espresso tests, see the Espresso documentation.

1. Changes to the build system

Add the Maven Central repository. Make sure you have a mavenCentral() entry in the build.gradle in your project root directory:

allprojects {
    repositories {

Add the following dependency in your app module's build.gradle file:


This code adds the Test Espresso Extensions as a dependency to your project, which ensures that the ReportHelper is available at compile time. The ReportHelper enables the label feature. See Step 3 for more detail on the label feature.

If you're using a version of Gradle lower that 3.0, then you might need to replace androidTestImplementation with androidTestCompile as explained in the gradle docs.

2. Changes to the tests

Step 1 - Add imports

Import these packages into your test classes:

import org.junit.Rule;
import org.junit.After;

Step 2 - Instantiate the ReportHelper

Insert this declaration in each of your test classes:

public ReportHelper reportHelper = Factory.getReportHelper();

Step 3 - Update your test cases

Using the helper still allows you to run your tests locally without additional modifications, but enables you to label test steps in your test execution using reportHelper.label("myTestStepLabel"). The label text is used to navigate the test steps and corresponding screenshots in the test report.

It's recommended to call label in the @After method, this call takes a screenshot of the app final state for the test report. The screenshot is taken even if a test fails. An example @After method for a test could look like this:

public void TearDown(){
    reportHelper.label("Stopping App");

To build the project and test apk files, run each of the following commands.

./gradlew assembleDebug
./gradlew assembleDebugAndroidTest


Your system path variable must include access to your machine's Java installation.

Once a test suite has been instrumented with the Test Cloud extensions, upload it to Test Cloud.