From android-unit-testing
Use when writing, completing, or reviewing unit tests for a Clean Architecture + MVVM Android app — Repository, UseCase, ViewModel, validators, DataStore wrappers, logic utils, or PagingSource. Targets ≥90% line coverage. Detects the project's mocking library (MockK or Mockito), JUnit version, and error model rather than assuming. Triggers on "write tests for", "add unit tests", "increase coverage", "test this ViewModel/Repository/UseCase".
How this skill is triggered — by the user, by Claude, or both
Slash command
/android-unit-testing:android-unit-testing [class or feature to test] e.g. LeaveViewModel, AuthRepository[class or feature to test] e.g. LeaveViewModel, AuthRepositoryThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generates and reviews JVM unit tests for the layers where business logic lives, to a
Generates and reviews JVM unit tests for the layers where business logic lives, to a
≥ 90% line-coverage bar on every Repository, UseCase, and ViewModel. The full
rules are project-agnostic and support both MockK and Mockito — the library, JUnit
version, error model, and file conventions are detected from the project, never assumed.
The complete ruleset is in reference/unit-testing-rules.md
(§ numbers below point into it). Copy-pasteable test skeletons are in
templates/ — templates/mockk/ and templates/mockito/, each with
repository_test.md, usecase_test.md, viewmodel_test.md.
Note: the reference doc historically calls the template path
codegen/templates/<library>/. In this skill the templates live attemplates/<library>/(relative to this SKILL.md).
Never write a test before completing these. Details in reference §0.
app/build.gradle.kts → applicationId; root every package/import there. (§0.1)gradle/libs.versions.toml / build.gradle.kts; never mix @Before+@BeforeEach. Ask if neither is present. (§0.2)templates/<library>/. Ask if both or neither (recommend MockK for Kotlin). (§0.2b)Resource/result wrapper + BaseRepository: typed AppError subtypes vs data-carrying message/statusCode. Assert against the actual mapping. (§0.2c)BaseRepositoryTest, MockResponseFactory, MainDispatcherRule, TestAssertHelper. Reuse what exists; propose additions and wait for confirmation. (§0.3)Source.kt functions vs dummy/XxxDummy.kt objects; follow the existing one, don't introduce the other. (§0.4)Event subclass, init {} side-effect; replace all Xxx placeholders with real names before writing. (§0.5)*Test.kt exists, read it, list covered branches, and ask whether to complete vs rewrite. Don't silently overwrite. (§0.6)./gradlew tasks --group verification; use the real test*UnitTest task and note jacoco vs kover. (§0.7)In scope: Repository, UseCase, ViewModel, Validators, DataStore/prefs wrappers, logic
utils, custom PagingSource. Out of scope: Compose UI tests, screenshot tests, E2E,
Room DAO queries, pure-passthrough navigation/theming. Full table in reference §1.
templates/<library>/<layer>_test.md).Event + init,
validation gates, state transitions via a state-collection helper).test*UnitTest task, then the coverage task (jacoco/kover,
§9). Report actual coverage; don't claim done until tests pass and the bar is met.| Need | Section in reference/unit-testing-rules.md |
|---|---|
| Onboarding / detection | §0 |
| Scope (what to test) | §1 |
| Toolchain: JUnit4 vs 5, MockK vs Mockito setup | §2 |
| Universal rules + library cheat-sheet | §3 |
| Harness/helper file templates | §4 |
| Per-layer rules (Repository / UseCase / ViewModel / DataStore / Paging) | §5 |
| Hitting 90% | §6 |
| Anti-patterns | §7 |
| Templates index | §8 |
| Coverage commands (jacoco / kover) | §9 |
| Worked example (Leave feature) | §10 |
The android-compose-review plugin's review skill flags missing tests on new
Repository/UseCase/ViewModel logic. When it does, use this skill to write them to standard.
Guides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
npx claudepluginhub ictech-projects/android-claude-skills --plugin android-unit-testing