Testing for Android Developers
Android testing is checking app behaviour with automated tests at several levels. Local unit tests run on the JVM for ViewModels and repositories, Compose UI tests verify what is shown on screen, and instrumentation tests run on a device or emulator for full integration with the framework.
Stage: Quality and Performance · Part of the Android Developer roadmap · Last reviewed 19 November 2026
What to learn in Testing
- Write a JUnit test for a ViewModel using fake repositories
- Test coroutines and Flow with runTest and Turbine-style collection
- Find and click nodes with the Compose test rule semantics
- Run an instrumentation test on an emulator from Gradle
- Decide which behaviour deserves a unit test versus a UI test
Testing interview questions
What is the difference between a local test and an instrumentation test?
Local tests live in the test source set and run on your computer's JVM, so they are fast but cannot use real Android APIs. Instrumentation tests live in androidTest and run on a device or emulator, giving access to the real framework at the cost of speed.
How do you test a Compose screen?
Use createComposeRule, set the composable content, then find nodes through the semantics tree with onNodeWithText or onNodeWithTag, perform actions such as performClick, and assert the result. Testing through semantics also encourages accessibility, since the same labels that screen readers use are the ones your tests find.
Where Testing fits in the Android Developer roadmap
Testing belongs to the Quality and Performance stage (beginner level), which takes about 5 hours. Reliable and fast.
Other units in this stage
Back to the full Android Developer roadmap