structuring-a-compose-test
CommunityBuild a stable, androidx-canonical Compose test
Software Engineering#jetpack-compose#ui-testing#compose-test-rule#hoisted-state#runonidle#androidjunit4#androidx-compose-test
Authorskydoves
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This skill fixes flaky or uncompilable Jetpack Compose UI tests caused by incorrect class structure, incorrect rule/entry-point usage, and state being created inside setContent instead of being hoisted for the test to drive.
Core Features & Use Cases
- Canonical test class skeleton: Enforces the androidx-style structure (typically @MediumTest, @RunWith(AndroidJUnit4::class), and a single createComposeRule(StandardTestDispatcher()) rule).
- Correct state ownership and lifecycle: Keeps mutable state declared above setContent so the test can mutate and re-assert reliably using rule.runOnIdle.
- Prevents incompatible patterns: Avoids mixing @get:Rule with runComposeUiTest { } and avoids calling setContent in @Before.
- Custom Activity support: Uses createAndroidComposeRule<MyActivity>() when the screen-under-test is not a ComponentActivity-backed default.
Quick Start
Ask the AI: “Show me the androidx-canonical skeleton for a Compose UI test that hoists mutable state above setContent and mutates it via rule.runOnIdle, without mixing @get:Rule and runComposeUiTest.”
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: structuring-a-compose-test Download link: https://github.com/skydoves/android-testing-skills/archive/main.zip#structuring-a-compose-test Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.