guillemroca/agent-skills-android/android-device-testing
Claude Code and agent skill by guillemroca/agent-skills-android
- community
Checking that the SKILL.md file is still in the repository.
Use when writing or debugging instrumented tests (Espresso, UI Automator, Compose test rules), using ADB, managing emulators, or inspecting UI with Layout Inspector.
Install
npx vskill@latest install guillemroca/agent-skills-android/android-device-testingSKILL.md
The same SKILL.md was published earlier as guillemroca/agent-skills-android/android-device-testing.
Android Device Testing
Overview
Test your app on real or emulated Android devices. This skill covers instrumented testing frameworks (Espresso, UI Automator, Compose testing), device management (ADB, emulators), UI inspection (Layout Inspector), and debugging tools for on-device behavior.
When to Use
- Writing instrumented tests (UI tests that run on a device/emulator)
- Debugging behavior that only reproduces on-device
- Setting up emulators for CI or local testing
- Inspecting UI hierarchy, accessibility, or layout issues
- Verifying behavior across API levels or screen sizes
Skip when: Writing unit tests that don't need a device (use JUnit5 + MockK instead).
Core Process
Step 1: Compose UI Testing
- Set up Compose test dependencies:
- Write Compose UI tests:
- Compose test selectors (prefer this order):
onNodeWithText("visible text")— most readableonNodeWithContentDescription("description")— for icons, imagesonNodeWithTag("test_tag")— last resort, addModifier.testTag("tag")- Avoid: index-based selection, parent traversal
Step 2: Espresso (View-based UI)
- Espresso for XML views or hybrid apps:
- Espresso with RecyclerView:
Step 3: UI Automator (Cross-app testing)
- UI Automator for system-level interactions:
Step 4: ADB Commands
- Essential ADB commands:
Step 5: Emulator Management
- Create emulators for testing matrix:
- Test across API levels:
- minSdk (verify compatibility)
- Target SDK (verify new behavior)
- Latest stable (verify forward compatibility)
- Key breakpoints: API 26 (minSdk common), API 31 (S changes), API 33 (notification permission), API 34 (photo picker, foreground service types), API 35 (edge-to-edge enforced, 16 KB page sizes), API 36 (predictive back on by default), API 37 (adaptive-by-default: orientation/resizability restrictions ignored on ≥600dp displays;
ACCESS_LOCAL_NETWORKpermission)
Step 6: android CLI for Deploy and Layout Assertions
- Use `android` CLI as a thin wrapper around `adb` + `avdmanager` + `emulator` when available (probe with
android --version; fall back to step 4/5 commands if absent):
``bash # Lifecycle: emulator → install → run → inspect android emulator list android emulator start --name Pixel_7_API_35 android run --apks=app/build/outputs/apk/debug/app-debug.apk android describe # locate built artifacts (JSON) ``
android run accepts a comma-separated APK list and an --activity flag; preferable to adb install -r + am start when you want a single deploy step that resolves the launcher activity automatically.
- Use `android layout` for state-change assertions (faster than re-running an instrumented test for one-off checks):
``bash # Snapshot before action, then diff after to see only what changed android layout --pretty --output=before.json adb shell input tap 540 1200 # perform the action android layout --diff # only nodes added/changed/removed since last snapshot ``
Useful during test authoring: lets you discover the exact resource-id, text, and bounds of the elements your test should assert on, without guessing from a screenshot. See ../../references/android-cli-reference.md.
Step 7: Screenshot Tests
- Lock UI in with JVM screenshot tests — no device, fast enough to run on every PR:
- Compose Preview Screenshot Testing (official
com.android.compose.screenshotplugin): reuses your@Previewcomposables. Record goldens with./gradlew updateDebugScreenshotTest, fail CI on diffs with./gradlew validateDebugScreenshotTest. - Roborazzi (Robolectric-based):
captureRoboImage()inside any Compose/Robolectric test — use when you need interactions before capture or non-Preview cases.
Use Preview Screenshot Testing by default (zero extra test code); reach for Roborazzi when a state can't be expressed as a preview. Keep goldens deterministic (fixed locale, font scale, time inputs) and commit them — a diff is a review artifact. Patterns in ../../references/testing-patterns.md.
Step 8: Journeys and Black-Box E2E
- Choose the right end-to-end layer:
| Tool | Nature | Use for | |
|---|---|---|---|
| Compose/Espresso tests | White-box, in-process | Screen and flow logic within the app; fastest feedback | |
Maestro (see android-e2e-verification) | Black-box YAML over adb | Deterministic acceptance flows per feature slice; release builds; CI | |
Journeys (android CLI / Android Studio) | AI vision + reasoning from natural-language steps | Exploratory E2E where maintaining selectors isn't worth it; resilient to layout churn but slower and less deterministic |
When driving the device ad hoc (reproducing a bug, verifying a fix), use the CLI's see-and-drive loop: android screen capture --annotate labels every element with #n, then android screen resolve --screenshot=... --string="input tap #5" translates the label into adb shell input coordinates. See ../../references/android-cli-reference.md.
Step 9: Layout Inspector
- Use Layout Inspector to debug:
- Open via Android Studio → Tools → Layout Inspector
- Inspect Compose hierarchy and recomposition counts
- Verify accessibility properties (content descriptions, roles)
- Check padding, margins, and alignment
- Compare with design specs
Step 10: Test Organization
- Test pyramid on Android:
Common Rationalizations
| Shortcut | Why It Fails | |
|---|---|---|
| "I tested manually, that's enough" | Manual testing doesn't catch regressions. Automated tests do. | |
| "Instrumented tests are too slow" | Slow tests that catch real bugs beat fast tests that miss them. Run in CI. | |
| "I'll just test on my device" | Your device is one API level, one screen size. The matrix matters. | |
| "Compose tests are flaky" | Flaky tests usually have timing issues. Use waitUntil and proper assertions. |
Red Flags
- No instrumented tests for critical user flows
- Tests only run on one API level
- Hardcoded delays (
Thread.sleep) instead of idling resources orwaitUntil - Tests depend on device state (network, locale, permissions)
- No Compose test rules for Compose-based screens
- Emulator setup not documented or automated
Verification
- [ ] Critical user flows have instrumented tests
- [ ]
./gradlew connectedAndroidTestpasses - [ ] Tests use proper waiting mechanisms (no
Thread.sleep) - [ ] Compose tests use semantic selectors (text, content description)
- [ ] Test matrix covers minSdk and targetSdk
- [ ] CI runs instrumented tests on emulator
- [ ] Screenshot tests exist for key screens and pass (
./gradlew validateDebugScreenshotTestor Roborazzi) - [ ] Layout Inspector shows expected hierarchy and accessibility info
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/android-device-testing/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/guillemroca/agent-skills-android/android-device-testing)