# androidx.compose.ui.test.v2

Common/AllAndroid/JVM

## Top-level functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestEnvironment<A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)( activityProvider: () -> A? )` Creates an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)` that retrieves the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` by delegating to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)`. | android |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestEnvironment<A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)( config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig, crossinline activityProvider: () -> A? )` Creates an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)` that retrieves the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` by delegating to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)`. | android |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestEnvironment<A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> [AndroidComposeUiTestEnvironment](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0))( effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html, crossinline activityProvider: () -> A? )` **This function is deprecated.** Use AndroidComposeUiTestEnvironment(config, activityProvider) instead. | android |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.SuspendFunction1)( noinline block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.SuspendFunction1)( activityClass: https://developer.android.com/reference/java/lang/Class.html<A>, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. | android |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)( config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig, noinline block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)( activityClass: https://developer.android.com/reference/java/lang/Class.html<A>, config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. | android |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> [runAndroidComposeUiTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1))( effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html, noinline block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` **This function is deprecated.** Use runAndroidComposeUiTest(config: ComposeUiTestConfig, block) instead. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> [runAndroidComposeUiTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1))( activityClass: https://developer.android.com/reference/java/lang/Class.html<A>, effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` **This function is deprecated.** Use runAndroidComposeUiTest(activityClass, config: ComposeUiTestConfig, block) instead. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.SuspendFunction1)(block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Sets up the test environment, runs the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.SuspendFunction1)` and then tears down the test environment. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)(config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Sets up the test environment, runs the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)` and then tears down the test environment. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[runComposeUiTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1))( effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` **This function is deprecated.** Use runComposeUiTest(config, block) instead. | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runEmptyComposeUiTest(kotlin.Function1)(block: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that does not launch an Activity to host Compose content in and thus acts as an "empty shell". | android |

## Top-level functions

### AndroidComposeUiTestEnvironment

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:AndroidComposeUiTestEnvironment)

```
fun <A : ComponentActivity> AndroidComposeUiTestEnvironment(
    activityProvider: () -> A?
): AndroidComposeUiTestEnvironment<A>
```

Creates an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)` that retrieves the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` by delegating to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)`. Use this if you need to launch an Activity in a way that is not compatible with any of the existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runEmptyComposeUiTest(kotlin.Function1)` methods.

Valid use cases include, but are not limited to, creating your own JUnit test rule that implements `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest` by delegating to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestEnvironment#test()`. See `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` for a reference implementation.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)` is called every time `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` is called, which in turn is called when `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` is called.

The most common implementation of an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)` retrieves the activity from a backing `https://developer.android.com/reference/kotlin/androidx/test/core/app/ActivityScenario` (that the caller launches *within* the lambda passed to `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`), but one is not limited to this pattern.

The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` sets the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Touch()` for each test. To configure the test to run with a different input mode (such as `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Keyboard()`) or customize other environment settings, use the overload that accepts a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be interacted with, which typically (but not necessarily) is the activity that was launched and hosts the Compose content. |
| `activityProvider: () -> A?` | A lambda that should return the current Activity instance of type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.Function0)`, if it is available. If it is not available, it should return `null`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestFlags#isInputModeSetForDeviceTests()` |   |

### AndroidComposeUiTestEnvironment

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:AndroidComposeUiTestEnvironment)

```
inline fun <A : ComponentActivity> AndroidComposeUiTestEnvironment(
    config: ComposeUiTestConfig,
    crossinline activityProvider: () -> A?
): AndroidComposeUiTestEnvironment<A>
```

Creates an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)` that retrieves the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` by delegating to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)`. Use this if you need to launch an Activity in a way that is not compatible with any of the existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runEmptyComposeUiTest(kotlin.Function1)` methods.

Valid use cases include, but are not limited to, creating your own JUnit test rule that implements `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest` by delegating to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestEnvironment#test()`. See `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` for a reference implementation.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)` is called every time `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` is called, which in turn is called when `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` is called.

The most common implementation of an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)` retrieves the activity from a backing `https://developer.android.com/reference/kotlin/androidx/test/core/app/ActivityScenario` (that the caller launches *within* the lambda passed to `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`), but one is not limited to this pattern.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be interacted with, which typically (but not necessarily) is the activity that was launched and hosts the Compose content. |
| `config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` used to set up the test environment, providing control over the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used for composition, the test timeout, and other environment-specific settings. |
| `crossinline activityProvider: () -> A?` | A lambda that should return the current Activity instance of type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function0)`, if it is available. If it is not available, it should return `null`. |

### AndroidComposeUiTestEnvironment

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:AndroidComposeUiTestEnvironment)

```
inline fun <A : ComponentActivity> [AndroidComposeUiTestEnvironment](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0))(
    effectContext: CoroutineContext = kotlin.coroutines.EmptyCoroutineContext,
    runTestContext: CoroutineContext = kotlin.coroutines.EmptyCoroutineContext,
    testTimeout: Duration = kotlin.time.Duration.parse("60s"),
    crossinline activityProvider: () -> A?
): AndroidComposeUiTestEnvironment<A>
```

> [!CAUTION]
> **This function is deprecated.**   
> Use AndroidComposeUiTestEnvironment(config, activityProvider) instead. The individual parameters \`effectContext\`, \`runTestContext\`, and \`testTimeout\` have been consolidated into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: AndroidComposeUiTestEnvironment(effectContext, runTestContext, testTimeout, activityProvider) After: AndroidComposeUiTestEnvironment(ComposeUiTestConfig(effectContext, runTestContext, testTimeout), activityProvider), use this instead:
>
> ```kotlin
> AndroidComposeUiTestEnvironment(ComposeUiTestConfig(effectContext, runTestContext, testTimeout), activityProvider)
> ```

Creates an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)` that retrieves the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` by delegating to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)`. Use this if you need to launch an Activity in a way that is not compatible with any of the existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runEmptyComposeUiTest(kotlin.Function1)` methods.

This implementation uses `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` by default for running composition. This ensures that the test behavior is consistent with `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` and provides explicit control over coroutine execution order. This means you may need to explicitly advance time or run current coroutines when testing complex coroutine logic, as tasks are queued on the scheduler rather than running eagerly.

Valid use cases include, but are not limited to, creating your own JUnit test rule that implements `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest` by delegating to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestEnvironment#test()`. See `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` for a reference implementation.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)` is called every time `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest#activity()` is called, which in turn is called when `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` is called.

The most common implementation of an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)` retrieves the activity from a backing `https://developer.android.com/reference/kotlin/androidx/test/core/app/ActivityScenario` (that the caller launches *within* the lambda passed to `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`), but one is not limited to this pattern.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be interacted with, which typically (but not necessarily) is the activity that was launched and hosts the Compose content. |
| `effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = kotlin.coroutines.EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to run the composition. The context for `LaunchedEffect`s and `rememberCoroutineScope` will be derived from this context. If this context contains a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-dispatcher/index.html`, it is used for composition and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MainTestClock`. Otherwise, a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` is created and used. This new dispatcher will share the `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)` if one is present. |
| `runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = kotlin.coroutines.EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to create the context to run the test. By default it will run using `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)` must not share `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html`. |
| `testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html = kotlin.time.Duration.parse("60s")` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html` within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. |
| `crossinline activityProvider: () -> A?` | A lambda that should return the current Activity instance of type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#AndroidComposeUiTestEnvironment(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.Function0)`, if it is available. If it is not available, it should return `null`. |

### runAndroidComposeUiTest

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:runAndroidComposeUiTest)

```
inline fun <A : ComponentActivity> runAndroidComposeUiTest(
    noinline block: suspend AndroidComposeUiTest<A>.() -> Unit
): Unit
```

Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. Be aware that if the Activity `https://developer.android.com/reference/kotlin/androidx/activity/compose/package-summary#(androidx.activity.ComponentActivity).setContent(androidx.compose.runtime.CompositionContext,kotlin.Function0)` during its launch, you cannot use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` on the ComposeUiTest anymore as this would override the content and can lead to subtle bugs.

Avoid using `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` (e.g., createComposeRule) inside `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.SuspendFunction1)` or any of their respective variants. Since these APIs independently manage the test environment, mixing them may lead to unexpected behavior.

The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` sets the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Touch()` for each test. To configure the test to run with a different input mode (such as `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Keyboard()`) or customize other environment settings, use the overload that accepts a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content. |
| `noinline block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestFlags#isInputModeSetForDeviceTests()` |   |

### runAndroidComposeUiTest

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:runAndroidComposeUiTest)

```
fun <A : ComponentActivity> runAndroidComposeUiTest(
    activityClass: Class<A>,
    block: suspend AndroidComposeUiTest<A>.() -> Unit
): Unit
```

Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. Be aware that if the Activity `https://developer.android.com/reference/kotlin/androidx/activity/compose/package-summary#(androidx.activity.ComponentActivity).setContent(androidx.compose.runtime.CompositionContext,kotlin.Function0)` during its launch, you cannot use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` on the ComposeUiTest anymore as this would override the content and can lead to subtle bugs.

Avoid using `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` (e.g., createComposeRule) inside `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.SuspendFunction1)` or any of their respective variants. Since these APIs independently manage the test environment, mixing them may lead to unexpected behavior.

The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` sets the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Touch()` for each test. To configure the test

- to run with a different input mode (such as `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Keyboard()`)

- or customize other environment settings, use the overload that accepts a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content. |
| `activityClass: https://developer.android.com/reference/java/lang/Class.html<A>` | The `https://developer.android.com/reference/java/lang/Class.html` of the Activity type to be launched, corresponding to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.SuspendFunction1)`. |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTestFlags#isInputModeSetForDeviceTests()` |   |

### runAndroidComposeUiTest

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:runAndroidComposeUiTest)

```
inline fun <A : ComponentActivity> runAndroidComposeUiTest(
    config: ComposeUiTestConfig,
    noinline block: suspend AndroidComposeUiTest<A>.() -> Unit
): Unit
```

Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. Be aware that if the Activity `https://developer.android.com/reference/kotlin/androidx/activity/compose/package-summary#(androidx.activity.ComponentActivity).setContent(androidx.compose.runtime.CompositionContext,kotlin.Function0)` during its launch, you cannot use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` on the ComposeUiTest anymore as this would override the content and can lead to subtle bugs.

Avoid using `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` (e.g., createComposeRule) inside `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)` or any of their respective variants. Since these APIs independently manage the test environment, mixing them may lead to unexpected behavior.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content. |
| `config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` used to set up the test environment, providing control over the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used for composition, the test timeout, and other environment-specific settings. |
| `noinline block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

### runAndroidComposeUiTest

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:runAndroidComposeUiTest)

```
fun <A : ComponentActivity> runAndroidComposeUiTest(
    activityClass: Class<A>,
    config: ComposeUiTestConfig,
    block: suspend AndroidComposeUiTest<A>.() -> Unit
): Unit
```

Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. Be aware that if the Activity `https://developer.android.com/reference/kotlin/androidx/activity/compose/package-summary#(androidx.activity.ComponentActivity).setContent(androidx.compose.runtime.CompositionContext,kotlin.Function0)` during its launch, you cannot use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` on the ComposeUiTest anymore as this would override the content and can lead to subtle bugs.

Avoid using `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` (e.g., createComposeRule) inside `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)` or any of their respective variants. Since these APIs independently manage the test environment, mixing them may lead to unexpected behavior.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content. |
| `activityClass: https://developer.android.com/reference/java/lang/Class.html<A>` | The `https://developer.android.com/reference/java/lang/Class.html` of the Activity type to be launched, corresponding to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)`. |
| `config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` used to set up the test environment, providing control over the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used for composition, the test timeout, and other environment-specific settings. |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

### runAndroidComposeUiTest

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:runAndroidComposeUiTest)

```
inline fun <A : ComponentActivity> [runAndroidComposeUiTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1))(
    effectContext: CoroutineContext = kotlin.coroutines.EmptyCoroutineContext,
    runTestContext: CoroutineContext = kotlin.coroutines.EmptyCoroutineContext,
    testTimeout: Duration = kotlin.time.Duration.parse("60s"),
    noinline block: suspend AndroidComposeUiTest<A>.() -> Unit
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use runAndroidComposeUiTest(config: ComposeUiTestConfig, block) instead. The individual parameters \`effectContext\`, \`runTestContext\`, and \`testTimeout\` have been consolidated into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: runAndroidComposeUiTest\<Activity\>(effectContext, runTestContext, testTimeout) { ... } After: runAndroidComposeUiTest\<Activity\>(ComposeUiTestConfig(effectContext, runTestContext, testTimeout)) { ... }, use this instead:
>
> ```kotlin
> runAndroidComposeUiTest<A>(ComposeUiTestConfig(effectContext, runTestContext, testTimeout), block)
> ```

Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. Be aware that if the Activity `https://developer.android.com/reference/kotlin/androidx/activity/compose/package-summary#(androidx.activity.ComponentActivity).setContent(androidx.compose.runtime.CompositionContext,kotlin.Function0)` during its launch, you cannot use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` on the ComposeUiTest anymore as this would override the content and can lead to subtle bugs.

This implementation uses `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` by default for running composition. This ensures that the test behavior is consistent with `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` and provides explicit control over coroutine execution order. This means you may need to explicitly advance time or run current coroutines when testing complex coroutine logic, as tasks are queued on the scheduler rather than running eagerly.

Avoid using `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` (e.g., createComposeRule) inside `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` or any of their respective variants. Since these APIs independently manage the test environment, mixing them may lead to unexpected behavior.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content |
| `effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = kotlin.coroutines.EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to run the composition. The context for `LaunchedEffect`s and `rememberCoroutineScope` will be derived from this context. If this context contains a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-dispatcher/index.html`, it is used for composition and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MainTestClock`. Otherwise, a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` is created and used. This new dispatcher will share the `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` if one is present. |
| `runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = kotlin.coroutines.EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to create the context to run the test `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`. By default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` will run using `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` must not share `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html`. |
| `testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html = kotlin.time.Duration.parse("60s")` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html` within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. |
| `noinline block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

### runAndroidComposeUiTest

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:runAndroidComposeUiTest)

```
fun <A : ComponentActivity> [runAndroidComposeUiTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1))(
    activityClass: Class<A>,
    effectContext: CoroutineContext = EmptyCoroutineContext,
    runTestContext: CoroutineContext = EmptyCoroutineContext,
    testTimeout: Duration = 60.seconds,
    block: suspend AndroidComposeUiTest<A>.() -> Unit
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use runAndroidComposeUiTest(activityClass, config: ComposeUiTestConfig, block) instead. The individual parameters \`effectContext\`, \`runTestContext\`, and \`testTimeout\` have been consolidated into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: runAndroidComposeUiTest(activityClass, effectContext, runTestContext, testTimeout) { ... } After: runAndroidComposeUiTest(activityClass, ComposeUiTestConfig(effectContext, runTestContext, testTimeout)) { ... }

Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that allows you to specify which Activity should be launched. Be aware that if the Activity `https://developer.android.com/reference/kotlin/androidx/activity/compose/package-summary#(androidx.activity.ComponentActivity).setContent(androidx.compose.runtime.CompositionContext,kotlin.Function0)` during its launch, you cannot use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` on the ComposeUiTest anymore as this would override the content and can lead to subtle bugs.

This implementation uses `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` by default for running composition. This ensures that the test behavior is consistent with `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` and provides explicit control over coroutine execution order. This means you may need to explicitly advance time or run current coroutines when testing complex coroutine logic, as tasks are queued on the scheduler rather than running eagerly.

Avoid using `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` (e.g., createComposeRule) inside `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` or any of their respective variants. Since these APIs independently manage the test environment, mixing them may lead to unexpected behavior.

| Parameters |
|---|---|
| `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity>` | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content |
| `activityClass: https://developer.android.com/reference/java/lang/Class.html<A>` | The `https://developer.android.com/reference/java/lang/Class.html` of the Activity type to be launched, corresponding to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`. |
| `effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to run the composition. The context for `LaunchedEffect`s and `rememberCoroutineScope` will be derived from this context. If this context contains a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-dispatcher/index.html`, it is used for composition and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MainTestClock`. Otherwise, a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` is created and used. This new dispatcher will share the `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` if one is present. |
| `runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to create the context to run the test `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`. By default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` will run using `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runAndroidComposeUiTest(java.lang.Class,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` must not share `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html`. |
| `testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html = 60.seconds` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html` within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/AndroidComposeUiTest<A>.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

### runComposeUiTest

Cmn android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.+function:runComposeUiTest)

```
fun runComposeUiTest(block: suspend ComposeUiTest.() -> Unit): Unit
```

Sets up the test environment, runs the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.SuspendFunction1)` and then tears down the test environment. Use the methods on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.SuspendFunction1)` 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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest` outside of this function is an error.

The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` sets the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Touch()` for each test. To configure the test

- to run with a different input mode (such as `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/InputMode#Keyboard()`)

- or customize other environment settings, use the overload that accepts a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`.

```kotlin
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.InputMode
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ComposeUiTestConfig
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.v2.runComposeUiTest

runComposeUiTest(
        config =
            ComposeUiTestConfig(
                effectContext = StandardTestDispatcher(),
                runTestContext = StandardTestDispatcher(),
                testTimeout = 30.seconds,
                inputMode = InputMode.Touch,
            )
    ) {
        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"))
    }
```

| Parameters |
|---|---|
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

### runComposeUiTest

Cmn android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.+function:runComposeUiTest)

```
fun runComposeUiTest(config: ComposeUiTestConfig, block: suspend ComposeUiTest.() -> Unit): Unit
```

Sets up the test environment, runs the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)` and then tears down the test environment. Use the methods on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(androidx.compose.ui.test.ComposeUiTestConfig,kotlin.coroutines.SuspendFunction1)` 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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest` outside of this function is an error.

```kotlin
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.InputMode
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ComposeUiTestConfig
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.v2.runComposeUiTest

runComposeUiTest(
        config =
            ComposeUiTestConfig(
                effectContext = StandardTestDispatcher(),
                runTestContext = StandardTestDispatcher(),
                testTimeout = 30.seconds,
                inputMode = InputMode.Touch,
            )
    ) {
        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"))
    }
```

| Parameters |
|---|---|
| `config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig` used to set up the test environment, providing control over the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used for composition, the test timeout, and other environment-specific settings. |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

### runComposeUiTest

Cmn android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.+function:runComposeUiTest)

```
fun [runComposeUiTest](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1))(
    effectContext: CoroutineContext = kotlin.coroutines.EmptyCoroutineContext,
    runTestContext: CoroutineContext = kotlin.coroutines.EmptyCoroutineContext,
    testTimeout: Duration = kotlin.time.Duration.parse("60s"),
    block: suspend ComposeUiTest.() -> Unit
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use runComposeUiTest(config, block) instead. The individual parameters \`effectContext\`, \`runTestContext\`, and \`testTimeout\` have been consolidated into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: runComposeUiTest(effectContext, runTestContext, testTimeout) { ... } After: runComposeUiTest(ComposeUiTestConfig(effectContext, runTestContext, testTimeout)) { ... }, use this instead:
>
> ```kotlin
> runComposeUiTest(ComposeUiTestConfig(effectContext, runTestContext, testTimeout), block)
> ```

Sets up the test environment, runs the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` and then tears down the test environment. Use the methods on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/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 `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` 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.

This implementation uses `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` by default for running composition. This ensures that the test behavior is consistent with `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` and provides explicit control over coroutine execution order. This means you may need to explicitly advance time or run current coroutines when testing complex coroutine logic, as tasks are queued on the scheduler rather than running eagerly.

This function follows the semantics of `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`. On JVM and Native it behaves similarly to `runBlocking`. On web targets it returns a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-result/index.html` backed by a `Promise`.

For multiplatform tests, make the test return `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-result/index.html` and immediately return the result of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`. Keep assertions inside the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`, and do not execute code after this call.

Example:

```kotlin
@Test
fun myTest(): TestResult = runComposeUiTest {
    setContent { /* content under test */}
}
```

Keeping a reference to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest` outside of this function is an error.

See also:

- [kotlinx.coroutines.test.runTest](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/run-test.html)

- [TestResult](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-result/)

```kotlin
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.v2.runComposeUiTest

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"))
}
```

| Parameters |
|---|---|
| `effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = kotlin.coroutines.EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to run the composition. The context for `LaunchedEffect`s and `rememberCoroutineScope` will be derived from this context. If this context contains a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-dispatcher/index.html`, it is used for composition and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MainTestClock`. Otherwise, a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` is created and used. This new dispatcher will share the `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` if one is present. |
| `runTestContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html = kotlin.coroutines.EmptyCoroutineContext` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used to create the context to run the test `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)`. By default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` will run using `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html`. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` must not share `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html`. |
| `testTimeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html = kotlin.time.Duration.parse("60s")` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html` within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |

### runEmptyComposeUiTest

android Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/v2/ComposeUiTest.android.kt+function:runEmptyComposeUiTest)

```
fun runEmptyComposeUiTest(block: ComposeUiTest.() -> Unit): Unit
```

Variant of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runComposeUiTest(kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext,kotlin.time.Duration,kotlin.coroutines.SuspendFunction1)` that does not launch an Activity to host Compose content in and thus acts as an "empty shell". Use this if you need to have control over the timing and method of launching the Activity, for example when you want to launch it with a custom Intent, or if you have a complex test setup.

This implementation uses `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` by default for running composition. This ensures that the test behavior is consistent with `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/index.html` and provides explicit control over coroutine execution order. This means you may need to explicitly advance time or run current coroutines when testing complex coroutine logic, as tasks are queued on the scheduler rather than running eagerly.

When using this method, calling `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest#setContent(kotlin.Function0)` will throw an IllegalStateException. Instead, you'll have to set the content in the Activity that you have launched yourself, either directly on the Activity or on an `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/AbstractComposeView`. You will need to do this from within the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runEmptyComposeUiTest(kotlin.Function1)`, or the test framework will not be able to find the content.

Avoid using `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` (e.g., createComposeRule) inside `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/v2/package-summary#runEmptyComposeUiTest(kotlin.Function1)` or any of their respective variants. Since these APIs independently manage the test environment, mixing them may lead to unexpected behavior.

| Parameters |
|---|---|
| `block: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTest.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The test function. |