UI tests range from simple ‘smoke tests’ to complex end-to-end email sign-up verifications. As a tester or QA engineer, your task is to perform UI tests as efficiently as possible with minimal inconsistencies. Your solution frequently lies in test automation, where you can use a software framework to reliably perform the testing for you.
This article covers the importance of UI test automation and provides recommendations on which frameworks to use to test your Android applications.
Mailosaur is an API for automating email and SMS tests, which works with any testing framework, including Android frameworks like Espresso and Appium.
What is Android UI Testing?
When it comes to Android applications, a functional user interface (UI) is essential. To have a UI free of issues, you need to test it. Without UI testing, your app could crash, display incorrect information, or take users to places they are not meant to go. UI testing checks for errors before you release your app so users can have a bug-free experience.
Automated Android UI testing vs. manual testing
Manually testing your Android app’s user interface is still necessary when looking at design elements and colours or user experience (UX), where a software program can offer no input. For these areas, you’ll need actual humans to assess if the UI is meeting the requirements.
For other types of checks, such as button presses and filling out forms, you can use test automation framework. A computer performs automated Android UI testing in a repeatable manner, with little to no inconsistencies between test runs. Eliminating user variation and error is an optimal way to find bugs in your program.
Automated UI testing also allows you to scale the number of features in your Android app without increasing the number of people on your QA team. Once a QA engineer writes a script, the test automation framework executes the test. This frees up the QA engineer to write new test scripts or run any required manual tests.
Some scenarios are notoriously hard to test, including signups and password resets with email or SMS. For a while, the only option was to test SMS and email manually. Now tools like Mailosaur help automate these aspects through APIs.
Selecting the best frameworks for automated Android UI testing
To identify the best frameworks for automated Android UI testing, we set two important criteria.
First, the framework’s developer must actively maintain the framework. This ensures the framework is compatible with the latest version of the Android operating system. Also, a framework must be completely free to download and use, without requiring any payment to access features.
Top frameworks for Android UI testing
With these two criteria in mind, here are our top three frameworks for Android UI testing.
Espresso / UIAutomator2
Espresso is Google’s framework for automated UI testing on Android applications. The company launched Espresso in 2013, giving testers a stable platform to create and execute reliable UI tests. Espresso is focused on Android and does not support any other operating system such as iOS.
UIAutomator2 is another Google framework for testing user interfaces. It compliments Espresso by being able to interact with multiple apps including system apps like Settings, where Espresso only automates the app under test. Both frameworks can be combined in the same test file if needed.
Espresso and UIAutomator2 are free to download and use, and Google keeps these frameworks up to date with the latest version of the Android operating system.
Espresso has a lot of depth, letting testers create tests in either the Java or Kotlin programming languages. For those with less coding experience, Espresso has a built-in Test Recorder that doesn’t require writing code.
By linking up an Android device or emulator, you can build a test script by walking the Test Recorder through each step you want Espresso to perform. The framework then saves the test, allowing you to repeat the test as many times as you need to in the future.
Appium is a mobile-specific test automation framework that executes UI tests for both Android and iOS devices using the same test code. Appium achieves cross-platform support by translating Appium test commands into Android- and iOS-specific equivalents.
The framework has a large following, with over 14,000 stars in their Github repository. Appium is completely free to use and is also open-source who wish to add in their own changes. Appium’s developers release updates every few months to accommodate newer versions of Android OS.
Detox is another cross-platform test automation framework, allowing users to perform end-to-end UI testing on mobile devices. Detox can use either an Android emulator or an actual mobile device connected to a computer.
Detox is developed and maintained by web development service Wix, and the framework has a history of frequent updates. These updates fix issues and add features to stay compatible with the latest version of Android. In addition, Detox is free to download and use for your UI tests.
TestProject is a test automation framework that’s designed for point-and-click style testing. The key feature of TestProject is the Recorder, a UI-based app for interactively creating test steps.
The framework’s focus on point-and-click testing is both its advantage and limitation, though. On one hand, non-technical users can create Android tests using TestProject’s UI-based test recorder. On the other hand, the recorded tests can’t be reused between test steps, and the effectiveness of an Android test strategy with TestProject will always be limited because of this inability to share and reuse code between various parts of the test suite.
Android UI testing frameworks: honourable mentions
You can still use the following frameworks for testing, but they miss the mark on our criteria.
Microsoft developed Calabash for UI test automation on both Android and iOS devices. However, Microsoft discontinued support on Calabash after the final releases of the iOS 11 and Android 8 operating systems. Without updates, compatibility with future OS versions is an open question.
Robotium is a framework dedicated to executing UI tests on Android devices. Unfortunately, the Github site and the framework itself have not seen any update since September 2016.
Which test automation framework to use?
Although the choices are somewhat sparse, there should be at least one framework on this list to meet your Android UI testing needs.
If you find yourself working on an Android native app and do not plan to create an equivalent in iOS, use Espresso/UIAutomator2 for your test scripts. Thanks to their focus on Android, Espresso combined with UIAutomator2 offer speed, stability, and easy setup that larger frameworks like Appium do not. Espresso only supports Java and Kotlin, so if you want non-engineering team members to contribute to Android tests, they will need to learn one of these two languages.
Should your app be destined for use on both Android and iOS, Appium is the better choice. You can use one set of test scripts to vet your app on both operating systems. Appium also allows test writers to create scripts using a number of programming languages, which means that even those without Android programming experience can be involved in test creation.
Detox is an up-and-coming framework but does not currently have a community as large as Espresso’s or Appium’s. It can be more difficult to get Detox-specific questions answered because there are fewer users who know the framework inside out. However, the framework is being actively developed and is likely to add more community members and features in the future. It’s worth having Detox on your radar.
Automate email sign-ups and more with Mailosaur
In this article, we covered three of the best Android UI testing frameworks on the market, namely Espresso, Appium, and Detox.
Mailosaur’s API provides you with email addresses and mobile numbers for automated responses from your app. Any one of these frameworks pairs well with Mailosaur enabling you to see how your Android app handles sending automated email or SMS messages to mobile numbers or email addresses. Mailosaur makes it possible to see precisely what each one receives so you can verify your app is working as per your requirements.