choosing-test-rule-vs-runtest

Select Compose UI test entry points for JUnit4 rules versus suspending lambdas.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill choosing-test-rule-vs-runtest-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: choosing-test-rule-vs-runtest
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/compose/setup/choosing-test-rule-vs-runtest
Command: npx skills add https://github.com/trancee/MeshLink-template --skill choosing-test-rule-vs-runtest-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill resolves the confusion between JUnit4-based Compose test rules and the newer suspending lambda entry points, preventing common environment-mixing bugs and deprecation warnings.

Core Features & Use Cases

  • Entry Point Selection: Provides clear guidance on choosing between createComposeRule, createAndroidComposeRule, and runComposeUiTest based on your project architecture.
  • Migration Support: Helps developers transition from deprecated v1 test APIs to the recommended v2 APIs using StandardTestDispatcher.
  • Use Case: If you are encountering IllegalStateException: setContent can only be called once or are unsure how to handle custom Activity scenarios in your UI tests, this Skill provides the exact configuration pattern to follow.

Quick Start

Use the choosing-test-rule-vs-runtest skill to determine the correct Compose test entry point for your specific activity and coroutine requirements.

Frequently Asked Questions about choosing-test-rule-vs-runtest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use createComposeRule versus runComposeUiTest in Android testing?

Choose createComposeRule for standard JUnit4 tests and runComposeUiTest for suspending lambda entry points. Selecting the correct Compose UI test entry point prevents environment-mixing bugs and deprecation warnings.

How do I fix IllegalStateException setContent can only be called once in Compose UI testing?

Fix the IllegalStateException setContent can only be called once by selecting the proper Compose UI test entry point. Correct setContent lifecycle management configuration prevents this environment-mixing error.

How do I migrate to the Compose Multiplatform v2 test API using StandardTestDispatcher?

Migrate to the v2 test API by transitioning from deprecated v1 test APIs to runComposeUiTest using StandardTestDispatcher. This ensures proper test clock synchronization for your Compose Multiplatform test suites.

Does runComposeUiTest support custom Activity scenarios in Jetpack Compose UI testing?

runComposeUiTest handles suspending lambdas rather than custom Activity scenarios. For custom Activity scenarios in Jetpack Compose UI testing, use createAndroidComposeRule to manage the setContent lifecycle properly.

Why am I getting deprecation warnings using createComposeRule in my Compose Multiplatform test suites?

Deprecation warnings from createComposeRule occur when using outdated v1 test APIs. Migrate your Compose Multiplatform test suites to the recommended v2 APIs using StandardTestDispatcher to clear these warnings.