This guide defines Android-specific standards for unit, Compose UI, and Hilt-integrated tests, including state and ViewModel invariants, entity and repository contracts, and choosing an appropriate test layer. It recommends coroutine test utilities, fakes, accessibility-semantic checks, and meaningful negative assertions, while prohibiting brittle state-copy assertions, shallow mock echoes, real network use, and `Thread.sleep`.
86%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Universal anti-slop rules (naming, identity fixtures, tautologies, skip/focus, mock echoing, bug-first lock, sleeps, shallow assertions, coverage): anti-slop-rules.md. Only Android deltas follow.
[MOB-TEST-02] State & ViewModel Invariant: Assert UI state transitions (StateFlow/UiState via Turbine test {}); ban
asserting copies of 30-property state. Under runTest with StandardTestDispatcher, advance virtual time with
advanceUntilIdle() or Turbine before asserting (GUARD-KT-02).[MOB-TEST-03] Entity Invariant & Serialization: Test calculations, validations, domain invariants, and non-trivial
serialization/parsing or error mapping. Ban tests of generated code and trivial getters.[MOB-TEST-04] Contract Testing: Repositories and data sources must prove contract compliance and error mapping; ban 1:1
stub-return echoes (GUARD-KT-01: coEvery { dataSource.get() } returns x; repo.get() == x).[MOB-TEST-06] Layer & Device Fidelity: Select layer (Unit > Compose UI > UiAutomator). In-memory tests cannot prove device
behavior. Activity recreation (recreate()) is same-process only; true OS process death requires external device termination
and relaunch.runTest with MainDispatcherRule; inject
DispatcherProvider rather than reading Dispatchers.Main. Mock with MockK or fakes.createAndroidComposeRule + HiltAndroidRule; replace modules with
@TestInstallIn fakes.onNodeWithContentDescription on interactive nodes (semantic tree only; does not prove device
TalkBack focus traversal or audio announcements); verify touch bounds ≥ 48dp.MOB-TEST-02, GUARD-KT-02): Ban whole-state copy assertions and
assertions on uncompleted coroutines without advanceUntilIdle() or Turbine.MOB-TEST-04, GUARD-KT-01): Ban shallow assertions without contract checks.Thread.sleep: Fake repositories in DI; use IdlingResource or composeTestRule.waitUntil for async
timing.HoangNguyen0403/agent-skills-standard
726dfda
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.