
Android Testing
Set up unit, Hilt integration, and Roborazzi screenshot tests for a Compose Android app aligned with Now in Android patterns.
Overview
android-testing is an agent skill for the Ship phase that guides unit, Hilt integration, and Roborazzi screenshot testing for Compose Android apps.
Install
npx skills add https://github.com/new-silvermoon/awesome-android-agent-skills --skill android-testingWhat is this skill?
- Testing pyramid: unit (ViewModels, repos), integration (Room, Retrofit/MockWebServer), UI/screenshot (Compose)
- Version-catalog snippets for JUnit4, coroutines-test, Espresso, Compose ui-test, Hilt testing, Roborazzi
- Hilt integration test patterns for DI-heavy Android modules
- Screenshot testing with Roborazzi for Compose UI regression detection
- Guidance aligned with Google Now in Android reference architecture
- 3-layer testing pyramid: unit, integration, UI/screenshot
Adoption & trust: 529 installs on skills.sh; 835 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Android app lacks a coherent test pyramid and you are unsure which libraries and patterns fit Compose, Hilt, and data layers.
Who is it for?
Indie developers building Kotlin/Compose Android apps who want NiA-style testing without rereading Google samples.
Skip if: iOS or Flutter projects, backend-only APIs, or teams that only need manual QA checklists with no automation.
When should I use this skill?
User is implementing or improving automated tests for a Kotlin/Compose Android codebase.
What do I get? / Deliverables
You get a structured testing approach with catalog-ready dependencies and layer-appropriate test examples to reduce regressions before release.
- Test module structure recommendations
- Dependency catalog entries
- Layer-specific test examples
Recommended Skills
Journey fit
How it compares
Architecture and testing playbook skill, not a CI service or Firebase Test Lab integration.
Common Questions / FAQ
Who is android-testing for?
Solo Android builders using agent-assisted coding who need expert test layering for Compose, Hilt, and data modules.
When should I use android-testing?
During Ship/testing when adding or refactoring tests before a release, or when onboarding screenshot coverage for Compose screens.
Is android-testing safe to install?
Review the Security Audits panel on this Prism page; the skill is documentation-first and does not require extra network access by itself.
SKILL.md
READMESKILL.md - Android Testing
# Android Testing Strategies This skill provides expert guidance on testing modern Android applications, inspired by "Now in Android". It covers **Unit Tests**, **Hilt Integration Tests**, and **Screenshot Testing**. ## Testing Pyramid 1. **Unit Tests**: Fast, isolate logic (ViewModels, Repositories). 2. **Integration Tests**: Test interactions (Room DAOs, Retrofit vs MockWebServer). 3. **UI/Screenshot Tests**: Verify UI correctness (Compose). ## Dependencies (`libs.versions.toml`) Ensure you have the right testing dependencies. ```toml [libraries] junit4 = { module = "junit:junit", version = "4.13.2" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" } androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version = "1.1.5" } espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version = "3.5.1" } compose-ui-test = { group = "androidx.compose.ui", name = "ui-test-junit4" } hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "hilt" } roborazzi = { group = "io.github.takahirom.roborazzi", name = "roborazzi", version.ref = "roborazzi" } ``` ## Screenshot Testing with Roborazzi Screenshot tests ensure your UI doesn't regress visually. NiA uses **Roborazzi** because it runs on the JVM (fast) without needing an emulator. ### Setup 1. Add the plugin to `libs.versions.toml`: ```toml [plugins] roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" } ``` 2. Apply it in your module's `build.gradle.kts`: ```kotlin plugins { alias(libs.plugins.roborazzi) } ``` ### Writing a Screenshot Test ```kotlin @RunWith(AndroidJUnit4::class) @GraphicsMode(GraphicsMode.Mode.NATIVE) @Config(sdk = [33], qualifiers = RobolectricDeviceQualifiers.Pixel5) class MyScreenScreenshotTest { @get:Rule val composeTestRule = createAndroidComposeRule<ComponentActivity>() @Test fun captureMyScreen() { composeTestRule.setContent { MyTheme { MyScreen() } } composeTestRule.onRoot() .captureRoboImage() } } ``` ## Hilt Testing Use `HiltAndroidRule` to inject dependencies in tests. ```kotlin @HiltAndroidTest class MyDaoTest { @get:Rule var hiltRule = HiltAndroidRule(this) @Inject lateinit var database: MyDatabase private lateinit var dao: MyDao @Before fun init() { hiltRule.inject() dao = database.myDao() } // ... tests } ``` ## Running Tests * **Unit**: `./gradlew test` * **Screenshots**: `./gradlew recordRoborazziDebug` (to record) / `./gradlew verifyRoborazziDebug` (to verify)