How to get started with automated testing of an Android application
Updated:
Start Android app automation with a small set of journeys where a defect would block a user or a release. The first test should check a specific outcome, such as a saved booking. Launching the app and performing a few taps does not establish that its main feature works.
Before choosing a tool, prepare the app build, test environment, accounts and a way to restore data. These conditions often determine whether the team gets a useful result on the next run too.
Choose the first journeys by the consequences of failure
Three to five important scenarios are enough to start. Select them with someone who knows the product, support requests and common user problems. Neither the number of screens nor the ease of recording steps is a useful measure of priority.
| Journey | What the test should demonstrate | What needs preparing |
|---|---|---|
| First launch | The user can reach the initial feature | A clean installation and specified permission decisions |
| Sign-in | The correct account can access its part of the app | A test account and known session state |
| Main operation | Booking, submission or saving produces the right result | Data that another test will not change |
| Payment, if supported | Confirmation, rejection and pending states are distinguished correctly | The provider’s test mode |
| Returning to the app | The user can continue according to the product rules | A defined state before leaving |
Do not check every form validation error through a phone. Calculations and validation can often be tested closer to the code. The Android testing strategy guide distinguishes test scopes and recommends choosing the lowest layer that answers the question. A short end-to-end journey then checks whether the screens, app and server work together.
Agree on the expected outcome before writing the test
Consider a model booking app. The account has no bookings, a specified slot is available in the test environment, and the test books it. Success means that the user sees the correct slot in their booking list. If the objective also includes checking server-side persistence, verify that through a separate available interface.
A “Done” message alone may not meet this objective. Conversely, checking every internal database field in every UI test may add unnecessary work. Decide what evidence this scenario needs and which details another layer already covers.
Record the prerequisites, steps, assertions and data cleanup. For invalid sign-in, an error message may be insufficient. Depending on the requirement, you may also need to confirm that the protected area did not open. The test must distinguish a correct rejection from an unavailable server.
Prepare the build and restorable data
The team needs to know which app it is installing and where it connects. Record the application ID, build version or commit, build variant and test backend address. Check that the package installs on the selected device and includes the required configuration.
Before the first repeated run, also resolve these questions:
- Who creates accounts, and how are they restored to a known state?
- What does the app reset locally, and what remains on the server?
- What test modes do payment, email or identity verification services offer?
- Can concurrent tests use the same account without affecting each other?
- How is a booking or order cleaned up after failure?
Clearing app data does not delete a booking on the server. A subsequent test signing in with the same account may encounter the previous run’s result. Give parallel scenarios separate accounts or data unless the test explicitly checks concurrency.
Keep production payments and customer accounts out of the first pilot. If CAPTCHA or a one-time code prevents repeatable setup, agree on a safe testing process for the non-production environment. This must not become a way to bypass protection in the public app. The guide to E2E test data covers preparation in more detail.
Choose a tool using a representative scenario
Appium and Maestro may both be candidates, but choose according to the specific app and team. Appium with the UiAutomator2 driver needs a configured server, driver, Android SDK, JDK and an available device. Check version requirements for the selected driver. Maestro describes journeys in YAML and controls the device through system interfaces.
Choose a pilot journey that includes a more complex part of your app. This might be a WebView, a system permission or a custom control. A simple opening screen will not reveal those limitations.
Assess whether the tool finds elements, prepares state, provides understandable assertions and runs in CI. Consider the team’s knowledge and maintenance when the app changes. See the Appium and Maestro comparison for more detail.
Check whether elements can be found reliably
Coordinate-based taps are sensitive to resolution, the keyboard and layout changes. Prefer an available stable identifier or an unambiguous name that matches the element’s purpose. Include localised text in the plan if the app supports multiple languages.
The Maestro selector documentation describes both text and identifiers. Android Compose test tags need to be exposed as resource IDs for external access. Adding a tag to the code alone therefore does not demonstrate that the chosen tool can see it.
An element the tool cannot see may require an app change. Check this with a developer before creating many workarounds. Tie waiting to an expected state with a reasonable limit. A fixed pause does not prove that loading or saving has finished.
Use emulators and phones according to risk
Start with one known configuration where you can reproduce the result. An emulator suits regular short checks. Add a physical device when you need to check particular hardware features or behaviour under usage conditions. Passing on an emulator does not establish compatibility with every phone.
Expand the matrix according to supported Android versions, available user data and reported defects. Consider a smaller display, a different font size or a device with important hardware. Do not combine every journey with every configuration without a clear reason.
Depending on the app’s features, add permission denial, backgrounding, returning, orientation changes or a network outage. Agree on the expected behaviour first. Should an unfinished form remain? Should the operation be repeated, or should only its status be refreshed? A test that accepts every dialogue automatically does not check behaviour after denial.
Separate clean installation from updates
A clean installation starts without old local app data. An update should instead check the preservation or migration of what the user already had. Resetting before every test does not cover the second problem.
If updates carry risk, prepare an older supported build with known state. Then install the new build in a way that matches the update being tested, and check sign-in and important saved data. Label this scenario separately so that general cleanup does not invalidate it.
Add CI when failure evidence is useful
Short critical journeys can run on changes, with a broader matrix in scheduled runs or before release. The split depends on test cost, duration and purpose. The first CI run should use the same build, data and assertions as the successful local pilot.
When a test fails, save the app and device identification, tool versions, test log and an available screenshot or recording. Include whether setup, device connection, interaction or the final assertion failed. Avoid unnecessary passwords or personal data in these artefacts.
Before expanding the suite, the team must be able to prepare a clean start, reproduce the result and explain a failure without assembling the environment manually. Assign ownership of data, maintenance and report assessment. Then add more journeys. Automation should complement focused manual and exploratory testing, particularly for new features and unusual combinations of behaviour.