compose-testinglisted
Install: claude install-skill pablitoarango/android-skills
# Compose UI Testing
Sources of truth: [Test your Compose layout](https://developer.android.com/develop/ui/compose/testing), [Testing APIs](https://developer.android.com/develop/ui/compose/testing/apis), [Synchronization](https://developer.android.com/develop/ui/compose/testing/synchronization), [Common patterns](https://developer.android.com/develop/ui/compose/testing/common-patterns), [Accessibility testing](https://developer.android.com/develop/ui/compose/accessibility/testing).
If the project defines its own UI test conventions (for example page objects or a mocked HTTP layer for instrumented tests), follow those for that kind of test. For overall test strategy, ViewModel tests and screenshot tests, see `android-testing`.
## 1. Setup
```kotlin
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
androidTestImplementation("androidx.compose.ui:ui-test-junit4-accessibility")
debugImplementation("androidx.compose.ui:ui-test-manifest")
testImplementation("androidx.compose.ui:ui-test-junit4")
testImplementation("org.robolectric:robolectric")
```
- The same test code runs as a local test with Robolectric or as an instrumented test.
- `createComposeRule()`: test composables in isolation; no Activity access needed.
- `createAndroidComposeRule<ComponentActivity>()`: when you also need Activity resources (`composeTestRule.activity.getString(...)`). Use `createAndroidComposeRule<YourActivity>()` for a real screen, including mixed View and Compose screens.
## 2. Test