android-testing
Skill0 starsChanged 32 days agoMITView on GitHub
Android testing discipline: test taxonomy and source sets, Gradle scopes for test-only dependencies, Robolectric placement, the deprecated ActivityTestRule, and Espresso synchronization without sleeps. Use when writing or reviewing local unit tests, instrumented tests, Robolectric tests, or Espresso tests. Core rules have machine checks in checks/.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- geertberkers/claude-skillstheir own version, first seen Oct 11, 2026
- lennonpetrick/android-engineering-skillstheir own version, first seen Oct 11, 2026
- maxrave-dev/SimpMusictheir own version, first seen Oct 8, 2026
- earlzdev/android-drivertheir own version, first seen Sep 7, 2026
- Shekhar23/claude-zero-to-hero-android-KMPtheir own version, first seen Mar 29, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- maxrave-dev/SimpMusic★ 13ksame name
- lennonpetrick/android-engineering-skills★ 40same name
- Shekhar23/claude-zero-to-hero-android-KMP★ 9same name
- earlzdev/android-driver★ 0same name
- geertberkers/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- compose-architectureSkill
- compose-migrationSkill
- compose-multiplatformSkill
- compose-performanceSkill
- compose-testingSkill
- dependency-injectionSkill
- gradle-build-logicSkill
- kmp-fundamentalsSkill
- material3-themingSkill
- offline-firstSkill
- release-engineeringSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 3 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
After ANY Android test edit, run the Verification step (bottom of this file).
- Very specific: line 21
MUST put JVM tests in module-name/src/test/ and device tests in module-name/src/androidTest/.
- Very specific: line 24
MUST live in src/test/, never in src/androidTest/.
- Very specific: line 45
MUST declare test-only libraries in the scope of the source set that uses them: testImplementation for local tests (JUnit, Mockito, MockK, …
- Very specific: line 72
MUST NOT use androidx.test.rule.ActivityTestRule (deprecated).
- Very specific: line 91
MUST NOT Thread.sleep / SystemClock.sleep in instrumented tests.
- Distinctive: line 114
Test doubles: prefer fakes over mocks — the official fundamentals examples construct the object under test with a fake repository, and the …
- Distinctive: line 118
Test pyramid balance, CI sharding, parameterized tests — strategy decisions, not text patterns.
- Distinctive: line 123
Run after every Android test edit (from the project root):
- Very specific: line 132
All four must pass (exit 0) before declaring the task done.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Android Testing
Operational rules for a coding agent. RIGHT/WRONG pairs are canonical.
After ANY Android test edit, run the Verification step (bottom of this
file). Compose UI tests are covered by the compose-testing skill.
1. Taxonomy — where a test lives
MUST put JVM tests in module-name/src/test/ and device tests in
module-name/src/androidTest/. Robolectric runs a simulated Android
environment inside a JVM — it is a local-test tool: Robolectric tests
MUST live in src/test/, never in src/androidTest/. The official
conversion path says exactly that: an instrumented test becomes a
Robolectric test by moving it to the test source set.
Robolectric setup (both pieces required):
android {
testOptions { unitTests { isIncludeAndroidResources = true } }
}
dependencies {
testImplementation("org.robolectric:robolectric:4.13")
}WHY: androidTest code needs a device or emulator and runs an order of
magnitude slower. A Robolectric test parked in androidTest silently
turns a fast local suite into an instrumentation run.
2. Dependency scope — test libs never ship in the APK
MUST declare test-only libraries in the scope of the source set that uses
them: testImplementation for local tests (JUnit, Mockito, MockK,
Robolectric), androidTestImplementation for instrumented tests
(AndroidX Test core/runner/rules, Espresso, UI Automator). MUST NOT put
them on implementation/api — that puts the test framework on the
production classpath and ships it in the APK.
WRONG:
implementation("junit:junit:4.13.2")
implementation("io.mockk:mockk:1.13.11")RIGHT:
testImplementation("junit:junit:4.13.2")
testImplementation("io.mockk:mockk:1.13.11")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")Documented exception: espresso-idling-resource may be implementation
when production code references it — the set-up-project guide allows both,
depending on whether the dependency belongs on the app or the test APK
classpath.
3. Activity rule — no deprecated ActivityTestRule
MUST NOT use androidx.test.rule.ActivityTestRule (deprecated). Use
ActivityScenarioRule (androidx.test.ext.junit.rules) or ActivityScenario
(androidx.test.core.app); to touch the Activity under test use
scenario.onActivity {}.
WRONG:
@get:Rule
val rule = ActivityTestRule(LoginActivity::class.java)RIGHT:
@get:Rule
val rule = activityScenarioRule<LoginActivity>()4. Synchronization — Espresso tracks idle state
MUST NOT Thread.sleep / SystemClock.sleep in instrumented tests.
Espresso keeps track of the app under test's idle state (message queue,
AsyncTasks, registered idling resources) and lets you stay away from
waits, syncs, sleeps and polls. For background work Espresso cannot see
(custom threads, network callbacks), register an IdlingResource — do
not sleep.
WRONG:
onView(withId(R.id.greet_button)).perform(click())
Thread.sleep(2_000)
onView(withText("Hello Steve!")).check(matches(isDisplayed()))RIGHT:
onView(withId(R.id.greet_button)).perform(click())
onView(withText("Hello Steve!")).check(matches(isDisplayed()))
// synchronization is built in5. What the checks cannot see (review-verified)
- Test doubles: prefer fakes over mocks — the official fundamentals examples construct the object under test with a fake repository, and the local-tests guide says to avoid complex mocking and use fakes (or Robolectric shadows) instead.
- Test pyramid balance, CI sharding, parameterized tests — strategy decisions, not text patterns.
Verification
Run after every Android test edit (from the project root):
bash <skill-dir>/checks/check_robolectric_source_set.sh <project-or-src-dir>
bash <skill-dir>/checks/check_test_dep_scope.sh <project-or-src-dir>
bash <skill-dir>/checks/check_no_activity_test_rule.sh <test-src-dir>
bash <skill-dir>/checks/check_no_sleep_in_instrumented.sh <test-src-dir>All four must pass (exit 0) before declaring the task done. Checks are deterministic heuristics — they catch the documented anti-patterns above, not every testing bug. §5 is verified by review against references/testing-android.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

