Skill / SKILL.md

Structuring A Compose Test

skydoves/android-testing-skills

Use this skill to structure a Jetpack Compose UI test class the way androidx itself writes them — `@MediumTest` + `@RunWith(AndroidJUnit4::class)`, a single `createComposeRule(StandardTestDispatcher())` rule, hoisted `mutableStateOf` declared above `setContent { }`, and the Test → Find → Assert → Act → Re-assert flow. Covers when to use `createAndroidComposeRule<MyActivity>()` for custom Activities, how to drive state from outside the composition via `runOnIdle { }`, why state must NOT be hoisted inside `setContent`, and why `@get:Rule createComposeRule()` and `runComposeUiTest { }` MUST NOT both appear in the same test. Use when the developer asks "how do I write a Compose test", "where do I declare state", "how do I name the test class", "MediumTest vs LargeTest", "rule.setContent inside @Before", or shows a test class that won't compile or doesn't drive state from outside.
2 views 351 repository stars 0 commentsUpdated Nov 27, 2026
Overview

Use this skill to structure a Jetpack Compose UI test class the way androidx itself writes them — `@MediumTest` + `@RunWith(AndroidJUnit4::class)`, a single `createComposeRule(StandardTestDispatcher())` rule, hoisted `mutableStateOf` declared above `setContent { }`, and the Test → Find → Assert → Act → Re-assert flow. Covers when to use `createAndroidComposeRule<MyActivity>()` for custom Activities, how to drive state from outside the composition via `runOnIdle { }`, why state must NOT be hoisted inside `setContent`, and why `@get:Rule createComposeRule()` and `runComposeUiTest { }` MUST NOT both appear in the same test. Use when the developer asks "how do I write a Compose test", "where do I declare state", "how do I name the test class", "MediumTest vs LargeTest", "rule.setContent inside @Before", or shows a test class that won't compile or doesn't drive state from outside.

Installation & variants

Download the repository, including the skill’s supporting files.

git clone -- 'https://github.com/skydoves/android-testing-skills' skill-source

Use the complete skill-source/compose/patterns/structuring-a-compose-test directory with your client’s skill installer.

  • compose/patterns/structuring-a-compose-test

    main · SKILL.md

    Open installation source

    Source directory recorded from the imported repository path

Source directory compose/patterns/structuring-a-compose-test

Source instructions
Read source instructions

Open to load source instructions

Original SKILL.md

Open to load the original file

Included files
Source & validation
Source status
Awaiting source check
Format validation
Needs source review
Checked at
Pending source check
Content SHA-256
187d5daa1888e6cbeb9c1168729d0308da611dba3ef7d9c34311fa89d3496299
Format validation findings
  • Metadata requires string values.
Agent Skills specification
Discussion
Comments Be the First to Comment

Please log in to comment

    No comments yet

Related skills