android-instrumentation-testinglisted
Install: claude install-skill lenorebreakneck630/claude-zero-to-hero-android-KMP
# Android Instrumentation Testing
## Overview
Instrumentation tests run on a real device or emulator inside the Android runtime. They are the only way to test:
- Actual navigation transitions and back-stack behavior
- System permissions dialogs (UI Automator)
- Full Hilt injection graph wiring
- Database + network integration without fakes
- Cross-app interactions (share sheets, notifications, deep links)
They are slower than unit tests. Reserve them for flows where the real runtime matters. For simple UI rendering tests, prefer Compose unit tests with `createComposeRule()` (runs on JVM — see android-testing).
---
## Dependency Setup
```toml
# gradle/libs.versions.toml
[versions]
espresso = "3.6.1"
uiautomator = "2.3.0"
hilt-testing = "2.51.1"
[libraries]
espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
espresso-intents = { module = "androidx.test.espresso:espresso-intents", version.ref = "espresso" }
uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "uiautomator" }
hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt-testing" }
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" }
androidx-test-rules = { module = "androidx.test:rules", version = "1.6.1" }
```
```kotlin
// build.gradle.kts (module under test)
android {
defaultConfig {
testInstrumentationRunner = "com.example.app.HiltTestRunner"
}
}
dependencies