Preparing Espresso Tests for Upload

The steps necessary to prepare an app and its corresponding test suite for upload to App Center vary depending on the test framework being used. This document provides instructions for preparing Espresso tests for upload to Test Cloud. For guidance on authoring Espresso tests, see the Espresso documentation.

1. Changes to the build system

Add the JCenter Maven repository. Make sure you have a jcenter() 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 adds the Test Cloud 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 are 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.

A recommended practice is to have a call to label in the @After method, this includes a screenshot of the app final state in the test report. The screenshot is taken, even if a test is failing, and often provides valuable information as to why it does so. 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


You 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.