Technical docs‎ > ‎

Espresso Test Recorder

This page is deprecated. Redirecting to

Espresso Test Recorder is a new feature released in Android Studio 2.2 Preview 3 that makes it easy to generate automated UI tests by recording your own interactions on a device so you don't have to actually write any test code. The generated test code can then be used to run against a wide variety of device configurations to make sure your application works as expected. This will not only make you more productive, but it will also significantly increase the test coverage and quality of your app.

Espresso Test Recorder creates tests based on the Espresso Testing framework, which is part of the Android Testing Support Library (ATSL). To learn more about ATSL and Espresso refer to our best practices for testing guide.


  • Record UI Interactions for user flows within minutes

  • Add View assertions directly from the recording flow

  • Generate editable and reusable Espresso test code

  • Works on physical devices, virtual devices and cloud devices

  • Replay tests on your local development machine, Continuous Integration or Firebase Test Lab.

How to record a test

Recording a test using Espresso test recorder is really simply.

The following procedure shows how to create a test using the Android testing codelab app as an example. If you'd like to follow along, then download that sample app first.

1. Select Run > Record Espresso Test

A Device Chooser dialog appears, which lets you select a target device.

2. Select target device

To record a user flow, you first need to choose a device. Espresso test recorder supports all kinds of devices: physical devices, virtual devices and cloud devices. To record using your own device, connect it and select it under Connected Devices. To record using an emulator, select a device from Available Emulators or create a new virtual device by clicking Create new Emulator. Then click OK.

Espresso test recorder will now run a full build of your project and then show the Record your test window. If you see a dialog on your device saying "Attaching Debugger," this is expected because Espresso test recorder is using the debugger to log UI events.

3. Record your test

To record UI events start interacting with your device and you will see how the events are logged while you click through the user flow.

Because you haven't interacted with your device yet, the panel on the left says "No events recorded yet."

4. Click Floating Action Button to add a Note

Espresso Test Recorder logs a "Tap" event on the button with the ID fab_add_notes and the device updates to show the notes detail screen where you can enter the title of a new note.

5. Type title text "Happy Testing!"

Typing the text "Happy Testing!" into the Title input results in a new "Type" event for the view with the ID add_note_title.

6. Save the new note

Clicking the button with the ID fab_add_notes saves the note and logs the corresponding UI "Tap" event. Next, verify that the new note is displayed in the notes list.

7. Click Add Assertion button and save assertion

Clicking the Add Assertion Button creates an interactive screenshot of the current screen. You can then click on the "Happy Testing!" text, that you want to verify against. This will automatically pre-populate all the assertion values, the ID of the view, the view assertion (text is), and the text that you want to verify.

8. Click Save Assertion button and complete recording

Clicking the Save Assertion button logs an "Assert" event to the recording. The final step is to click Complete Recording, to generate the Espresso test code.

9. Pick a test class name and click Save

10. Inspect the generated code.

Saving your test in the previous step will immediately show the generated Espresso test code. Even though this is generated test code, the concise and fluent Espresso API makes it easy to read, understand and customize it to your needs.

11. Run your test

Right-click on the generated AddNotesScreenTest class and click Run AddNotesScreenTest. For more options to run your tests from Android studio tbd.

The generated test code can be run on your local development machine, on your Continuous Integration server CI, or on Firebase Test Lab. Moreover it can be used as a great learning tool for testing and working with the Espresso testing framework.

Happy Testing!