Android Testing: UIAutomator vs Espresso Android Testing: UIAutomator vs Espresso android android

Android Testing: UIAutomator vs Espresso


Actually, you don't need to choose. UIAutomator and Espresso use the same instrumentation runner, so you can use commands from both of them in a single test. Espresso has variety of matchers, assertions and actions on UI, that automator doesn't have:

Espresso Cheat Sheet

Espresso is running in separate thread and it is really fast comparing to other test frameworks.

as Summary: use both of them in your tests, Espresso is main and UIAutomator as an additional tool for OS integration.


UIAutomator – is powerful and has good external OS system integration e.g. can turn WiFi on and off and access other settings during test, but lacks backward compatibility as it requires Jelly Bean or higher. But, also lacks detailed view access so one could say it may be more of a pure black-box test. Where as Espresso has access to view internals (see below). This is recommended on developer.android.com for "Testing UI for Multiple Apps"

Espresso - is a bit more light weight compared to ui automator and supports 2.2 Froyo and up it also has a fluent api with powerful hamcrest(https://github.com/hamcrest) integration making code more readable and extensible (it is newer than Ui automator). It does not have access to system integration tests but has access to view internals e.g. can test a webview (useful for Hybrid app testing, or webview heavy testing). Slightly more grey-box testing compared to UI Automator. This is recommended on developer.android.com for "Testing UI for a Single App". As of Android Studio 2.2 this now offers UI test recording (like UIAutomator)


If you are testing only one application, then Espresso.

If you are testing more than one application or its integration with other applications or system, then UiAutomator.