In the fast-moving world of software development, mobile automation testing has become a crucial tool for success. Testing mobile applications presents a unique set of challenges: It takes considerable time and effort for manual testing teams to spend their valuable attention testing out each, individual feature on so many different hardware devices, operating systems and versions.

Automating your testing seems like an obvious alternative, but only if you can trust the process. This is fully-realized when your development team can make swift progress without fear of breaking any existing features. Automation will free your developers to confidently carry out needed changes in code, unafraid of the usual challenges.

Challenges Faced in Mobile Testing

  • The massive number of mobile devices on the market.
  • Addressing a variety of hardware configurations, including various memory, CPU and OS optimizations.
  • Accounting for multiple OS’ and their many versions.
  • Varying mobile application development methods: native app, responsive web app, and hybrid app.
  • Making frequent app updates.

Mobile development is meant to be agile, and many great tools and practices have been developed for that agility. However, doing something manually (like mobile testing) is never agile, which is why mobile automation testing has shown tremendous growth among experienced mobile app and game developers. It speeds up our workflow considerably, and consequently allows for more robust and better results in compatibility between users, devices and market.

Fortunately a lot of mobile automation testing tools are available, and Android Espresso is the best fit for Android applications.

Testing with Espresso: Introduction


Espresso is a testing framework for Android that makes it easy to write reliable user-interface tests. To make UI regression simple and time-saving for any Android application, Espresso offers three basic components:

  • ViewMatchers: Used to find the elements in the screen.
  • ViewActions: Used to perform gestures on the elements in the screen (e.g. click, swipe, etc.)
  • ViewAssertions: Used to check any action that is done on a element.

We’ll need the following basic tools to proceed with Android Espresso.

Testing with Espresso: Tools Needed


Android Studio is the official integrated development environment (IDE) for Google’s Android operating system. Therefore it’s designed specifically for Android development. You can download Android Studio on Windows, macOS and Linux-based operating systems.

The Android Software Development Kit (SDK) includes a suite of development tools, like debugger, libraries and a handset emulator.

Gradle is an open-source build automation system. It’s capable of automating the building, testing, publishing, deployment (and more) of software packages or other types of projects.

Espresso is our testing framework for Android and enables us to easily write reliable UI tests.

A repository is a central place in which a collection of data is kept and maintained in an organized way.

Testing with Espresso: Getting Started


Image description:

  1. Set up Espresso with Gradle
  2. Create an Espresso test class
  3. Import all required dependencies and necessary classes
  4. Connect the test device
  5. Run your automated test!

Espresso Test Recorder

Android Studio provides a Record Espresso Test feature which allows you to manually record an interaction with your application, then create an automated Espresso test from it. To start recording a test, follow these steps:

  • Click Run > Record Espresso Test
  • In the Select Deployment Target window, choose the device on which you want to record the test. If necessary, create a new Android Virtual Device. Click OK.
  • Follow the steps to record the UI test.
  • It’s that easy!

Android Espresso: Feature Comparison


Benefits of Mobile Automation Testing with Espresso

Benefits of mobile automation testing graphic.
  • It’s easy!
  • Far more agile, and saves time and resources.
  • Supports mobile testing activities outside the mobile app with UI automator.
  • Improved mobile UI test coverage.
  • Increases the efficiency and effectiveness of your mobile testing process.

As anybody in operations will tell you, repetitive tasks add up over time. A savings of seconds or minutes here-and-there translates into real money and time over the course of a project (or a year). So minimize your manual bottleneck with mobile automation testing. Introduce efficiencies into the process, and free your developers up to move at their agile best.

If you find your development process a little sluggish and think there’s room for improvement, then reach out to Modestack about our DevOps & Support services. We would love to partner with you and help get things up to speed.