choosing-test-rule-vs-runtest

Installation
SKILL.md

Choosing Test Rule vs runComposeUiTest — One Entry Point Per Test

Compose ships two parallel test entry points: a JUnit4 TestRule (createComposeRule() and friends) and a multiplatform suspending lambda (runComposeUiTest { }). Each one independently sets up the recomposer, MainTestClock, and IdlingResource. Mixing them in a single test produces double-environment bugs that are hard to diagnose. This skill picks the right one and surfaces the v1 → v2 deprecation that bites every existing codebase.

When to use this skill

  • The user is starting a new Compose UI test and is choosing between createComposeRule() and runComposeUiTest { }.
  • The IDE shows a deprecation WARNING on import androidx.compose.ui.test.junit4.createComposeRule or import androidx.compose.ui.test.runComposeUiTest.
  • The user reports tests passing on v1 entry points but breaking after migrating because LaunchedEffects no longer run synchronously.
  • The user has a custom ComponentActivity subclass and is unsure between createAndroidComposeRule and createEmptyComposeRule.
  • The user reports IllegalStateException: setContent can only be called once per ComposeTestRule or "the launched Activity already calls setContent".
  • The user is writing Compose Multiplatform (KMP) tests and needs the suspending entry point.

When NOT to use this skill

  • The dependencies do not yet compile — start with ./configuring-test-dependencies/SKILL.md.
  • The choice is host vs device, not rule vs lambda — see ./setting-up-host-vs-device-tests/SKILL.md.
  • The test compiles and runs but flakes on idle/animation — see ../../synchronization/synchronizing-with-idle/SKILL.md and ../../synchronization/testing-animations-deterministically/SKILL.md.
Installs
33
GitHub Stars
319
First Seen
May 26, 2026
choosing-test-rule-vs-runtest — skydoves/android-testing-skills