スキル一覧に戻る
shoheikawano

compose-test-generator

by shoheikawano

3🍴 0📅 2026年1月19日
GitHubで見るManusで実行

SKILL.md


name: compose-test-generator description: | Generate Compose UI tests for Android and Kotlin Multiplatform projects. Use when: (1) Writing tests for @Composable functions, (2) Creating screenshot/snapshot tests, (3) Testing state changes and user interactions in Compose UI, (4) Adding test coverage to screens. Triggers: "compose test", "ui test", "write tests for", "test this composable", "screenshot test", "paparazzi", "roborazzi", "compose testing". context: fork agent: general-purpose user-invocable: true allowed-tools:

  • Read
  • Write
  • Edit
  • Glob
  • Grep
  • Bash

Compose Test Generator

Generate idiomatic Compose UI tests following best practices.

Coding Standards

MANDATORY: This skill follows kotlin-compose-standards. All generated code MUST comply with these standards:

  • Trailing comma EXCEPT for Modifier arguments
  • Parameter order: required → Modifier → optional
  • Modifier passed last when calling composables
  • Each Modifier method on its own line
  • New line at end of file

Quick Start

class MyComponentTest {
    @get:Rule
    val composeTestRule = createComposeRule()

    @Test
    fun component_displaysCorrectly() {
        composeTestRule.setContent {
            MyComponent(text = "Hello")
        }

        composeTestRule.onNodeWithText("Hello").assertIsDisplayed()
    }
}

Workflow

  1. Read the composable to understand structure and state
  2. Identify test scenarios: happy path, edge cases, interactions
  3. Choose test type: behavior test, screenshot test, or both
  4. Generate test file in appropriate location
  5. Add test tags to composable if needed for reliable selection

References

FileWhen to Read
selectors.mdFinding nodes, test tags, semantic matchers
actions.mdClick, type, scroll, gesture actions
assertions.mdVisibility, state, content assertions
screenshot-tests.mdPaparazzi, Roborazzi setup and usage

Test Patterns

Stateless Component Test

@Test
fun button_showsLabel() {
    composeTestRule.setContent {
        PrimaryButton(label = "Submit", onClick = {})
    }
    composeTestRule.onNodeWithText("Submit").assertIsDisplayed()
}

Stateful Interaction Test

@Test
fun counter_incrementsOnClick() {
    composeTestRule.setContent {
        CounterScreen()
    }
    composeTestRule.onNodeWithText("0").assertIsDisplayed()
    composeTestRule.onNodeWithTag("increment_button").performClick()
    composeTestRule.onNodeWithText("1").assertIsDisplayed()
}

ViewModel Integration Test

@Test
fun screen_showsLoadedData() = runTest {
    val viewModel = MyViewModel(FakeRepository())

    composeTestRule.setContent {
        MyScreen(viewModel = viewModel)
    }

    composeTestRule.waitUntil {
        composeTestRule.onAllNodesWithTag("item")
            .fetchSemanticsNodes().isNotEmpty()
    }

    composeTestRule.onAllNodesWithTag("item").assertCountEquals(3)
}

Output Location

Place test files following project convention:

  • Android: app/src/androidTest/java/.../ or app/src/test/java/.../
  • KMP: shared/src/commonTest/kotlin/.../
  • Screenshot tests: Usually in src/test/ (JVM-based)

スコア

総合スコア

40/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です