Last week, we hosted a webinar on Espresso, the UI testing framework for Android native apps. As an introductory, it was great to see a mix of experiences and skill sets in the audience
We chose this topic because we see many customers interested in using Espresso, migrating from other frameworks, and combining testing technologies to include more testing in every build cycle.
Daniel: “What’s your opinion about using UIAutomator with Espresso? It’s a good practice?”
Answer: Espresso is great for testing app functionality, but is built to stop at the app/OS boundary. UIAutomator is great for controlling system properties. Google documents their individual usefulness here.
They *can be combined, as Alex Zhukovich explains in this article, but my personal opinion is that you should be careful of how much your Espresso tests depend on outside the app, to keep them fast and flakiness-free across platform versions. In cases where you *need to perform activities in Espresso code that are outside the default scope of the framework, be VERY clear about what/why you’re doing it (i.e. step up your documentation/commenting game in those cases).
UIAutomator also requires Android 4.3 (API level 18) or higher. If that’s not a problem for you, fantastic. If it is, you’ll probably need to adjust your test execution strategy to accommodate for maximum test and platform coverage in both cases.
Another great resource is the work Chiu-ki Chan has done around explaining and demonstrating various aspects of Espresso testing. She touches on UIAutomator in this video, and goes into depth about Intents, Idling, Dagger and Mockito use with Espresso here.
Tamish: “Is it possible to use espresso for apps build on Xamarin?”
Santosh: “Does Espresso support XPath at all?”
Answer: Yes, but Espresso tends to prefer utility functions for matching elements by properties, not path. Nevertheless, there are a few methods for XPath, as documented here.
Kiruthika: “Will it support IOS builds too?”
Answer: No. Espresso is for Android native apps only.
Lauren: “What integrations do you know for cucumber and Espresso?”
Answer: Good question! Others have driven Espresso execution using Cucumber and like every Cucumber implementation, it requires glue code, mapping of app identifiers and test actions. Here’s a great article by Alex Fogleman about how to do this. There are also numerous Github examples on the topic