← ClaudeAtlas

wnb-compose-ui-testlisted

Use this skill when writing, reviewing, or refactoring a Jetpack Compose UI test on Android. Enforces the canonical skeleton — @get:Rule createComposeRule(), an inline DispatcherProvider using Dispatchers.Unconfined so state propagates synchronously to the tree, a renderScreen(...) factory that constructs the ViewModel + sets content and returns the VM for assertion, semantics-first finders (onNodeWithText, onNodeWithTag, onNodeWithContentDescription, hasTestTag), Truth assertions on state, no Thread.sleep (waitForIdle / waitUntil instead), no hardcoded coordinates, no mocking of repositories (use fakes). Applies to instrumentation-style tests under app/src/androidTest. Triggers on "compose ui test", "createComposeRule", "androidTest", "instrumentation test", "onNodeWithText", "onNodeWithTag", "performClick", "performTextInput", "waitForIdle", "setContent", "compose test dispatcher", "test Screen composable".
wenubey/claude-android-skills · ★ 0 · Testing & QA · score 72
Install: claude install-skill wenubey/claude-android-skills
# Jetpack Compose UI test — canonical skeleton Every screen-level Compose test in this project has the same shape. Same rule, same dispatcher trick, same factory pattern, same finder discipline. Do not invent variants. Pairs with `[[wnb-viewmodel-udf]]` and `[[wnb-viewmodel-test]]` — a screen's ViewModel unit test verifies the state machine; this UI test verifies the state renders correctly and one critical interaction works. ## Non-negotiables 1. **`@get:Rule val composeTestRule = createComposeRule()`** — one rule per test class. Never `createAndroidComposeRule<Activity>()` unless you specifically need the host Activity (rare). 2. **Inline `DispatcherProvider` with `Dispatchers.Unconfined`** for all three (`main`, `io`, `default`). This makes VM state updates propagate to the tree synchronously — no missed emissions, no `advanceUntilIdle`. Only exception: tests that specifically need to inspect intermediate loading state can use a `StandardTestDispatcher` + `MainDispatcherRule` combo; the default is Unconfined. 3. **`renderScreen(...)` factory** at the top of every test class. Constructs the VM with defaultable fake repositories, calls `composeTestRule.setContent { XxxScreen(viewModel = vm, …) }`, and **returns the VM** so tests can assert against `vm.state.value` directly. 4. **Semantics-first finders**, in this preference order: - `onNodeWithTag("submitButton")` — best for interactive elements (add `Modifier.testTag(...)` in the composable). - `onNodeWithContentD