runComposeUiTest
@ExperimentalTestApi
expect fun runComposeUiTest(
    effectContext: CoroutineContext = EmptyCoroutineContext,
    runTestContext: CoroutineContext = EmptyCoroutineContext,
    testTimeout: Duration = 60.seconds,
    block: suspend ComposeUiTest.() -> Unit,
): TestResult
Sets up the test environment, runs the given test and then tears down the test
environment. Use the methods on ComposeUiTest in the test to find Compose content and make
assertions on it. If you need access to platform specific elements (such as the Activity on
Android), use one of the platform specific variants of this method, e.g.
runAndroidComposeUiTest on Android.
Implementations of this method will launch a Compose host (such as an Activity on Android) for
you. If your test needs to launch its own host, use a platform specific variant that doesn't
launch anything for you (if available), e.g. runEmptyComposeUiTest on Android. Always make sure
that the Compose content is set during execution of the test lambda so the test
framework is aware of the content. Whether you need to launch the host from within the test
lambda as well depends on the platform.
Keeping a reference to the ComposeUiTest outside of this function is an error.
Parameters
| effectContext | The CoroutineContextused to run the composition. The context forLaunchedEffects andrememberCoroutineScopewill be derived from this context. If this context contains aTestDispatcherorTestCoroutineScheduler(in that order), it will be used for composition and theMainTestClock. | 
| runTestContext | The CoroutineContextused to create the context to run the testblock. By defaultblockwill run usingkotlinx.coroutines.test.StandardTestDispatcher.runTestContextandeffectContextmust not shareTestCoroutineScheduler. | 
| testTimeout | The Durationwithin which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. | 
| block | The test function. | 
@ExperimentalTestApi
actual fun runComposeUiTest(
    effectContext: CoroutineContext,
    runTestContext: CoroutineContext,
    testTimeout: Duration,
    block: suspend ComposeUiTest.() -> Unit,
): TestResult
Parameters
| effectContext | The CoroutineContextused to run the composition. The context forLaunchedEffects andrememberCoroutineScopewill be derived from this context. If this context contains aTestDispatcherorTestCoroutineScheduler(in that order), it will be used for composition and theMainTestClock. | 
| runTestContext | The CoroutineContextused to create the context to run the testblock. By defaultblockwill run usingkotlinx.coroutines.test.StandardTestDispatcher.runTestContextandeffectContextmust not shareTestCoroutineScheduler. | 
| testTimeout | The Durationwithin which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. | 
| block | The suspendable test body. | 
Code Examples
RunComposeUiTestSample
@OptIn(ExperimentalTestApi::class)
fun RunComposeUiTestSample() = runComposeUiTest {
    var counter by mutableIntStateOf(1)
    setContent {
        Column {
            Text(text = "Count: $counter", modifier = Modifier.testTag("text_tag"))
            Button(onClick = { counter++ }, modifier = Modifier.testTag("button_tag")) {
                Text("Click Me!")
            }
        }
    }
    onNodeWithTag("button_tag").performClick()
    onNodeWithTag("text_tag").assert(hasText("Count: 2"))
}
