Skip to content
Development
Skill

/android-testing

Write Android unit, Compose UI, and Hilt-integrated tests. Use when designing test behavior with MockK or coroutine test utilities; defer database/WorkManager-specific recipes to the owning feature skill.

From plugin
agent-skills-standard
583200 skills21 agents33 commands1 MCP

Claude Code

$ npx -y skills add hoangnguyen0403/agent-skills-standard --skill android-testing --agent claude-code

SKILL.md

android-testing.SKILL.md
name: android-testing
description: Write Android unit, Compose UI, and Hilt-integrated tests. Use when designing test behavior with MockK or coroutine test utilities; defer database/WorkManager-specific recipes to the owning feature skill.
metadata:
  triggers:
    files:
    - '**/*Test.kt'
    - '**/*Rule.kt'
    keywords:
    - "@Test"
    - runTest
    - composeTestRule
    - HiltAndroidTest
    - MockK
    - createAndroidComposeRule
    - MainDispatcherRule
    - "@TestInstallIn"
    - android instrumentation test

Android Testing Standards

**Priority: P0 (CRITICAL)**

The Four-Pillar Test Value Framework

Qualitative reasoning framework to evaluate unit test value:

  • **Protection against Regressions**: Catches real defects; a test passing during failure offers zero protection.
  • **Resistance to Refactoring**: Decoupled from internal implementation; zero false alarms on internal refactorings.
  • **Fast Feedback**: Executes in milliseconds; rapid local TDD feedback loop.
  • **Maintainability**: Clean AAA structure, high readability, zero boilerplate duplication.

Avoid inventing arbitrary numeric scores (e.g. P * R * F * M) statically without empirical measurement.

Core Rule Anchors

  • **`[MOB-TEST-01]` Tripartite Naming**: Name tests `Method_Scenario_ExpectedBehavior` (e.g. `submitOrder_whenCreditLimitExceeded_displaysBlockedBanner`).
  • **`[MOB-TEST-02]` State & ViewModel Invariant Rule**: Assert UI state transitions (e.g. `StateFlow`/`UiState` via Turbine `test {}`); ban asserting 30-property boilerplate state copies.
  • **`[MOB-TEST-03]` Entity Invariant & Serialization Rule**: Test calculations, validations, domain invariants, and non-trivial serialization/parsing or error mapping. Ban testing auto-generated code, trivial getters, or echo tests repeating literal assignments.
  • **`[MOB-TEST-04]` Contract Testing Rule**: Repositories and data sources must be tested for contract compliance and error mapping. Ban 1:1 pass-through mock echoing (`coEvery { dataSource.get() } returns x; repo.get() == x`).
  • **`[MOB-TEST-05]` Bug-First Regression Lock**: Every PR fixing a bug ticket or with title `fix(...)` must introduce a failing test reproducing the defect before fixing it.
  • **`[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.

Implementation Guidelines

Unit Tests

  • **Scope & Async**: ViewModels, Usecases, Repositories, Utils. Use `runTest` with `MainDispatcherRule`. Mock with MockK or fakes.
  • **Coverage**: Coverage is diagnostic and project-configured; verify risk-weighted critical paths rather than padding code for an arbitrary percentage.

UI Integration Tests (Instrumentation)

  • **Scope & DI**: Composable Screens, Navigation flows. Use `createAndroidComposeRule` + Hilt (`HiltAndroidRule`). Fake repositories via `@TestInstallIn`.
  • **TalkBack Semantics**: Assert `onNodeWithContentDescription` on interactive nodes (semantic tree only; does not prove device TalkBack focus traversal or audio announcements); verify touch bounds ≥ 48dp.
  • **Negative Assertions**: Add negative assertions only when absence is part of the business contract.

Anti-Patterns & Banned Smells

  • **`[MOB-TEST-01]` Vague names**: Banish non-descriptive test names.
  • **`[MOB-TEST-02]` Brittle state copies**: Ban asserting 30-property boilerplate state copies; use focused state assertions or Turbine.
  • **`[MOB-TEST-03]` Echo tests**: Ban testing auto-generated code, trivial getters, or repeating literal assignments.
  • **`[MOB-TEST-04]` Pass-through mock echoing**: Ban 1:1 pass-through mock echoing and shallow assertions without contract checks.
  • **`[MOB-TEST-05]` Missing bug reproduction**: Ban bug fix PRs without reproduction tests.
  • **No Real Network / Thread.sleep**: Fake repositories in DI; use IdlingResource or `composeTestRule.waitUntil` for async timing.

References

  • [Test Rules](references/implementation.md)
  • [Mobile Testing Methodology](../../common/common-mobile-visual-testing/SKILL.md) — 10 mobile scope areas & C6 contract
Read more
@hoangnguyen0403
Ships withagent-skills-standard

The portable standards layer for AI coding agents. Sync once, then work in your own runtime.

583200 skills21 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
583
Star history of hoangnguyen0403/agent-skills-standard on GitHub, a chart by star-history.com

Other skills on agent-skills-standard.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills10d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc12d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react1d252k
@facebook@facebookInstall Skill

Questions about android-testing.

Which coding agents can use android-testing?
android-testing installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.