← ClaudeAtlas

android-testinglisted

Write and review Android/Kotlin tests across the pyramid: JUnit (4/5) unit tests, MockK, Turbine for Flow/StateFlow assertions, coroutine testing with runTest and test dispatchers, Robolectric JVM tests, Espresso instrumented UI tests, and Compose UI testing with createComposeRule and semantics matchers. Use when writing or fixing unit tests, testing coroutines/Flows, mocking dependencies, choosing JVM vs instrumented tests, or testing Compose UI and ViewModels on Android.
eric-sabe/engsys · ★ 1 · Testing & QA · score 67
Install: claude install-skill eric-sabe/engsys
# Android Testing Write and review tests for Android/Kotlin targeting JUnit, MockK, Turbine, kotlinx-coroutines-test, Robolectric, Espresso, and Compose UI testing. Favor a test pyramid: many fast JVM unit tests, fewer Robolectric/Compose tests, and a thin layer of instrumented end-to-end tests. Test behavior, not implementation. ## Contents - [Test Pyramid and Source Sets](#test-pyramid-and-source-sets) - [Unit Tests (JUnit)](#unit-tests-junit) - [Mocking with MockK](#mocking-with-mockk) - [Testing Coroutines](#testing-coroutines) - [Testing Flows with Turbine](#testing-flows-with-turbine) - [Testing ViewModels](#testing-viewmodels) - [Robolectric](#robolectric) - [Compose UI Testing](#compose-ui-testing) - [Espresso](#espresso) - [Common Mistakes](#common-mistakes) - [Review Checklist](#review-checklist) ## Test Pyramid and Source Sets | Location | Runs on | Use for | |---|---|---| | `src/test/` | Local JVM (`testDebugUnitTest`) | Logic, ViewModels, repos, mappers, Robolectric | | `src/androidTest/` | Device/emulator (`connectedDebugAndroidTest`) | Espresso, Compose UI, integration | Keep most tests in `src/test/` — they are fast and run in the unit-test gate. Reserve `src/androidTest/` for tests that genuinely need a device/emulator. ## Unit Tests (JUnit) JUnit 4 is still the Android default; JUnit 5 is fine for pure-JVM modules with the platform engine configured. Name tests by behavior. ```kotlin class PriceFormatterTest { @Test fun `formats whole dollar