The Power of Espresso UI automation

Haggai Brian
3 min readAug 13, 2020

Espresso

when it comes to automated Android UI testing, Appium loses to Espresso big time in terms of speed, stability, feedback and ease of configuration. But there’s one quality Appium has that helps it gain some points back in this Appium vs. Espresso battle. Appium allows parallel Android UI test execution, which is a critical feature for any company that wants to make the most out of continuous testing and integration.

If you are looking for a framework that will take care of automated Android UI testing better, go with Espresso. It’s a platform-specific tool that has many strong sides: it’s fast, reliable, stable and easy to work with. But if your app is cross-platform and you also need to test the iOS version, go with Appium. Bitbar’s mobile app testing platform provides premium support for both Appium and Espresso to automate your Android app testing.

Meet Espresso

Espresso created by Google is a native framework for Android automated testing. The tool is a part of the Android SDK and is easy to use for native mobile development. Thanks to Espresso, you can create tests that are close to the Android app’s logic. Let’s see what it has to offer for automated UI testing of Android apps.

Espresso’s Advantages

1. Stability and speed

Overall, Espresso is much more stable than Appium for automated Android UI testing. In addition to that, the execution of test scripts is much faster. All thanks to Espresso’s automatic synchronization of UI elements and test actions: the framework detects when an element is available for testing and runs test commands accordingly.

2. Simple workflow and fast feedback

Espresso allows compiling automated Android UI tests into a separate APK. This means that the test suite will run next to the app on the device, which is very convenient. On top of that, because Espresso doesn’t require server communication, it provides feedback faster than Appium.

3. Compact API

Another advantage is that Espresso has a simple and lightweight API with three components: viewMatchers, viewActions and viewAssertations. Espresso’s API makes Android UI tests easy to maintain and change. Also, it is customizable.

4. Effortless setup and integration with Android Studio

The setup process for Espresso is much more straightforward than for Appium. Moreover, Espresso is integrated with the native Android development environment — Android Studio. This makes Espresso easy to use if you are already familiar with Android instrumentation.

5. Everyone can use it

Without a doubt, Espresso is the UI automated testing tool of choice for Android developers. It’s integrated with Android Studio IDE and supports platform-specific languages. You may think that your QAs and other team members will find it difficult to use, but Google changed the targeting of its test automation tool just recently and made it possible for everyone to use Espresso. Now, thanks to Espresso Test Recorder, you can create tests for Android apps without having solid programming skills: simply record your interactions with the app instead of writing code.

Espresso’s Disadvantages

1. Limit in languages and technology stack

Espresso only supports Java and JUnit programming languages, which makes it a perfect tool for Android developers who are used to creating native apps. At the same time, it’s a drawback since it means you are limited in your stack.

2. Native to Android UI testing

Frankly, it’s really hard to say that this is a disadvantage since I am comparing Appium for automated Android UI testing. But today, almost every mobile team around the world develops and needs to test both Android and iOS apps. Choosing Espresso certainly means that you need to find a similar tool/framework for automating iOS UI testing. That doubles the work on creating and maintaining the test scripts.

On any day of my life as QA and Automation Engineer, I will choose Espresso for UI Automation over Appium because of the need to have all the tests in one code base and not have the test suite in different projects, but Espresso as a whole is a very good UI automation tool for me and I have used in my day to day activities. I do recommend it for UI automation in Android

--

--

Haggai Brian

Software Quality Assurance Engineer | Automation Engineer | Computer Engineer | Android Engineer | Tech Savy