Before you can start coding, there are a few things we need to take care of:
First up are the software requirements: downloading the project and installing the required software. When that’s done, we will cover a bit of app related terminology, to make sure we are all on the same page and know what ‘Activities’ and ‘Views’ are. And finally we will take a look at the basic setup of an Espresso test.

Project Setup

You will need the following software for UI automation with Espresso:

  • The source code of an App;
  • Android Studio, so we can open it and add our tests;
  • An emulator or device to run the app.

The source code for the App that I created for this workshop can be found on my GitHub page on the ‘espresso-for-beginners-start’ branch:

The project contains a ReadMe file with instructions that will help you download the app project, set up Android Studio, and install an emulator:

If everything is working as intended, take a few minutes to explore the different parts of the App:

  • Onboarding
  • Custom Order screen
  • List with menu items
  • Order Overview screen

Terminology: Activities and Views

During this course we will be launching Activities and looking for Views to automate. If you aren’t familiar with those yet, here are two posts you can read:

App Terminology for Testers: Activities
App Terminology for Testers: Views

Basic Test Setup

Before we start writing test, I would like to explain the basic test setup.

Open up in the nl.testchamber.mailordercoffeeshop AndroidTest package:

You will see the following code:

 public class EspressoWorkshopTest {

 public ActivityTestRule<MainActivity> activityTestRule = new

 public void dismissOnboarding() {
    onView(withId("Customize your order")));

There are three discernible parts:

  1. The class name (EspressoWorkShopTest). You’re allowed to choose whatever name you like. I would suggest using a name that covers what the test subject is;
  2. The TestRule. The ActivityTestRule takes care of launching our Activity for us before each test. It also closes the Activity after each test. At the end of this course we will take a closer look at the test rule.
  3. The test method. The ‘@Test’ annotation has to be added to each test (method) that we write. It enables running each method that we write as a separate test.

In our first exercise we’re going to turn this code into a working test, by finding and adding the right IDs.

Continue with part 2: Finding the right IDs