Espresso Framework
Espresso Framework

Espresso — Mobile Automation Framework for Android — Part 1

App Devops
3 min readOct 6, 2022

--

Introduction of Espresso:

There is a popular adage among android app developers which goes You don’t test android. Android tests you. For Android developers to write UI tests, they must be convinced that benefits of those test must outweigh the effort spent in building those tests. Google, being the proprietor of Android platform, took it upon them self to make the life of Android developers easy. Espresso is the solution that they came up with in 2013.

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.

Android Espresso a native testing framework developed by Google for testing User Interfaces of Android apps. It is:

  • A very light weight API. To be more precise, it is just some 600+ lines of code on top of the existing Android Instrumentation class.
  • An extremely simplified API that lets the developers create tests with only 3 interfaces corresponding to 3 actions — Find a view, perform an action on a view and perform an assertion a view.
  • Distributed with Android SDK and integrated with Android ecosystem as a part of AndroidX test framework.
  • Capable of creating reliable UI tests for Android apps that can be executed in Android Studio itself.
  • Offered with automated synchronization between test actions and the application’s UI components.
  • Offered with dedicated module to test Android WebView components
  • Offered with dedicated module to test and mock Android Intents
  • Compatible with JUnit TestRunner classes 3 and 4.

Benefits of Espresso:

  • Backward compatibility
  • Easy to setup.
  • Highly stable test cycle.
  • Supports testing activities outside application as well.
  • UI automation suitable for writing black box tests.
  • Tests, once created, can be run on any Android version after 4.0 Ice Cream Sandwich (API level 14) without any modifications.
  • The developers need not learn any new coding skills as Espresso tests can be written in either Java or Kotlin — The same languages that they use for developing android apps using Google’s Android SDK.
  • Android developers need not invest time in getting familiar with new libraries and their functionalities just to create tests. Espresso uses AndroidX Framework and Android Instrumentation class which they would already be familiar with.
  • The test runs are extremely fast as the automated synchronization feature runs the test step the next millisecond the thread becomes non-idle.
  • Tests can be written as in-app code (whitebox testing) as well as out-of-app scripts (blackbox testing)

Limitations:

  • As opposed to other mobile app testing tools, Espresso can only be used to test Android apps.
  • Currently Espresso cannot test push notification functionalities

Q&A

Q1 what are the languages supported by Espresso Framework?

a) Kotlin

b) Java

c) C#

d) Swift

Q2 Espresso is a Mobile Automation Framework , which is part of ___________

a) Android Studio

b) iOS Development IDE

c) MS Mobile

d) Xamerian

Ans:

Q1 - a & b

Q2 - a

--

--