In brief
A mobile app is tested on three kinds of devices. Android emulators and iOS simulators are enough for most logic and UI tests, because they are fast, cheap and easy to run in CI. Real devices are needed for the camera, biometrics, notifications, NFC, performance, battery and behavior on a weak network. A cloud device farm gives you access to many phone models without buying them for your desk. A good setup combines all three and picks the list of models based on what your customers use.
Emulator, simulator and real device
The Android Emulator in Android Studio simulates an Android device on your computer, so you can test an app on many configurations and API levels without owning every phone. The iOS Simulator in Xcode works differently: it does not reproduce iPhone hardware, it runs an app built for the simulator on a Mac. In both cases you are testing an approximation of a phone, not the phone itself.
| Attribute | Emulator and simulator | Real device | Cloud farm |
|---|---|---|---|
| Startup cost | Free vendor tools | Buying and maintaining phones | Per-minute fee or subscription |
| Startup speed | Seconds, in parallel in CI | Manual setup | Queue and device allocation time |
| Hardware fidelity | Limited | Full | Full for physical devices |
| Camera, NFC, biometrics | Simulated or unavailable | Real | Depends on the service and model |
| Performance and battery | Unreliable | Reliable | Reliable for physical devices |
| Number of models | Any profile | As many as you have in the drawer | A wide choice of models and OS versions |
The takeaway is practical: emulators for fast tests on every change, real devices for tests where hardware matters, and a farm for broad model coverage before a release.
What to test only on a real device
Some behavior looks different on an emulator than on the phone in a customer's hand, or does not show up at all. On real devices you check:
- biometrics and secure key storage, meaning sign-in with a fingerprint or face and the behavior after biometric data changes in the system;
- the camera, for example scanning an ID document or a QR code in poor light;
- NFC, for example contactless payments and reading chip-based documents;
- push notifications, including delivery when the app is closed or the system has put it to sleep;
- performance, memory and battery usage, covered in the article on mobile app performance;
- behavior on a weak network: switching from Wi-Fi to cellular, airplane mode in the middle of an operation, a slow connection;
- interruptions: an incoming call, switching apps, low battery, rotating the screen.
In banking apps this list is longer, because security and strong customer authentication requirements come on top. They are described in the article on mobile banking apps. On real devices it is also worth checking accessibility with the screen reader on, following the article on accessibility testing against WCAG 2.2.
Cloud device farms
A device farm is a service that provides phones and tablets in the vendor's data center. You send tests from CI or connect to a device remotely. Two examples from large vendors:
- AWS Device Farm lets you test Android, iOS and web apps on physical phones and tablets hosted by AWS, either through remote access to a device or through automated test runs, including with Appium.
- Firebase Test Lab runs tests on real devices in a Google data center and on virtual Android devices. It supports Android and iOS, including XCTest tests.
A farm pays off when customers use many models and OS versions and the team does not want to maintain a cabinet full of phones. Before choosing, check whether the models popular with your customers are available, where the devices physically sit and whether tests can reach the test environment in your network. With bank or insurer customer data, that last question can matter more than the price.
How to choose the device list
The test device list should come from data, not from whatever happens to be lying around the office. Data sources are app analytics, app store statistics and customer tickets. From that you build a matrix:
- OS versions. The latest Android and iOS version, the previous one and the oldest one the app officially supports.
- Android manufacturers. The few manufacturers with the largest share among your customers, because vendor skins change how notifications and battery saving behave.
- Screen sizes. A small phone, a typical phone, a large phone and a tablet if the app supports it.
- Weaker hardware. At least one older or cheaper model, where memory and smoothness problems show up.
Full regression runs on a few devices from the core of the list, and a broad matrix runs on the farm before a larger release. Review the list every few months, because the share of models and OS versions keeps changing.
Mobile test automation
Automation uses native and cross-platform tools:
- Espresso is Google's library for UI tests of Android apps, run together with the app;
- XCTest is Apple's framework for unit, performance and UI tests in Xcode projects;
- Appium is an open-source project for UI test automation across many platforms, including Android and iOS, with one API for both systems.
Native tools are usually faster and more stable, but you need two test suites. Appium lets you write a single suite in the team's language at the cost of slower execution. Whatever you choose, keep the proportions from the article on the test pyramid: check logic with unit and API tests and keep on-device tests for the key journeys. Mobile tests are especially prone to flakiness because of animations and response times, so the principles from the article on flaky tests come in handy. An example of full regression on both systems is the project on automating regression of a bank's mobile app on iOS and Android.
Questions and answers
Can a mobile app be tested on an emulator only?
Not entirely. Emulators and simulators are enough for most logic, UI and regression tests in CI. Biometrics, the camera, NFC, push notifications, performance, battery usage and behavior on a weak network have to be checked on real devices, because an emulator reproduces them only approximately or not at all. Before a release, at least the key journeys go through physical phones.
How many devices should a mobile app be tested on?
As many as your customer data suggests. A typical matrix covers the latest, previous and oldest supported OS version, a few of the most popular Android manufacturers, different screen sizes and one weaker model. Regression runs on a few devices from the core of the list, and a wider set runs on a cloud farm before a larger release.
Appium or Espresso and XCTest?
Espresso and XCTest are native, usually faster and more stable, but need separate tests for Android and iOS, often written by the app developers. Appium lets the test team write one suite in a familiar language for both systems, at the cost of slower execution and an extra layer. Many teams combine both: native tests in the app code and Appium for end-to-end journeys.
Is a cloud device farm safe for test data?
It can be, if you configure it well. Check where the devices are, how the vendor wipes them after a session and how tests connect to your environment. Use only test data on the farm, never a copy of customer data. Treat test accounts and API keys as secrets and revoke them when they are no longer needed.