Espresso is an open source android user interface (UI) testing framework developed by Google. The term Espresso is of Italian origin, meaning Coffee. Espresso is a simple, efficient and flexible testing framework. This tutorial walks you through the basics of Espresso framework, how to setup Espresso framework in a project, work flow of the framework and finding, automating & asserting user interface components in the testing environment with simple android application.
Audience
This tutorial is prepared for professionals who are aspiring to make a career in the field of android mobile application as well as android automated testing. This tutorial is intended to make you comfortable in getting started with the Espresso testing framework concepts.
Prerequisites
Before proceeding with the various types of concepts given in this tutorial, we assume that the readers have the basic knowhow of android mobile programming. In addition to this, it will be very helpful, if the readers have a sound knowledge on Java.
Introduction
In general, mobile automation testing is a difficult and challenging task. Android availability for different devices and platforms makes it things tedious for mobile automation testing. To make it easier, Google took on the challenge and developed Espresso framework. It provides a very simple, consistent and flexible API to automate and test the user interfaces in an android application. Espresso tests can be written in both Java and Kotlin, a modern programming language to develop android application.
The Espresso API is simple and easy to learn. You can easily perform Android UI tests without the complexity of multi-threaded testing. Google Drive, Maps and some other applications are currently using Espresso.
Features of Espresso
Some the salient features supported by Espresso are as follow,
- Very simple API and so, easy to learn.
- Highly scalable and flexible.
- Provides separate module to test Android WebView component.
- Provides separate module to validate as well as mock Android Intents.
- Provides automatic synchronization between your application and tests.
Advantages of Espresso
Let us now what the benefits of Espresso are.
- Backward compatibility
- Easy to setup.
- Highly stable test cycle.
- Supports testing activities outside application as well.
- Supports JUnit4
- UI automation suitable for writing black box tests.