# androidx.compose.ui.test.junit4.v2

Android/JVM

## Top-level functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<R, A>` | `<R : https://junit.org/junit4/javadoc/latest/org/junit/rules/TestRule.html, A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)( activityRule: R, activityProvider: (R) -> A )` Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, where compose content is hosted by an Activity. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<R, A>` | `<R : https://junit.org/junit4/javadoc/latest/org/junit/rules/TestRule.html, A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)( activityRule: R, config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig, activityProvider: (R) -> A )` Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, where compose content is hosted by an Activity. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<R, A>` | `<R : https://junit.org/junit4/javadoc/latest/org/junit/rules/TestRule.html, A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> [AndroidComposeTestRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1))( activityRule: R, effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html, activityProvider: (R) -> A )` **This function is deprecated.** Use AndroidComposeTestRule(activityRule: R, config: ComposeUiTestConfig, activityProvider: (R) -\> A) instead. | android |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule<A>, A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule()()` Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given activity class type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule()`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule<A>, A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class)(activityClass: https://developer.android.com/reference/java/lang/Class.html<A>)` Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class)`. | android |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule<A>, A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(androidx.compose.ui.test.ComposeUiTestConfig)( config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig )` Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given activity class type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(androidx.compose.ui.test.ComposeUiTestConfig)`. | android |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule<A>, A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> [createAndroidComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(kotlin.coroutines.CoroutineContext))( effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html )` **This function is deprecated.** Use createAndroidComposeRule\<A\>(config: ComposeUiTestConfig) instead. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule<A>, A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class,androidx.compose.ui.test.ComposeUiTestConfig)( activityClass: https://developer.android.com/reference/java/lang/Class.html<A>, config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig )` Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class,androidx.compose.ui.test.ComposeUiTestConfig)`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule<https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule<A>, A>` | `<A : https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity> [createAndroidComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class,kotlin.coroutines.CoroutineContext))( 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 )` **This function is deprecated.** Use createAndroidComposeRule(activityClass: Class\<A\>, config: ComposeUiTestConfig) instead. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule()()` Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(androidx.compose.ui.test.ComposeUiTestConfig)(config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig)` Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule` | `[createComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext))(effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html)` **This function is deprecated.** Use createComposeRule(config: ComposeUiTestConfig) instead. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createEmptyComposeRule()()` Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, that doesn't create a compose host for you in which you can set content. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createEmptyComposeRule(androidx.compose.ui.test.ComposeUiTestConfig)(config: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig)` Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, that doesn't create a compose host for you in which you can set content. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` | `[createEmptyComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createEmptyComposeRule(kotlin.coroutines.CoroutineContext))(effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html)` **This function is deprecated.** Use createEmptyComposeRule(config: ComposeUiTestConfig) instead. | android |

## Top-level functions

### AndroidComposeTestRule

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

```
fun <R : TestRule, A : ComponentActivity> AndroidComposeTestRule(
    activityRule: R,
    activityProvider: (R) -> A
): AndroidComposeTestRule<R, A>
```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, where compose content is hosted by an Activity.

The Activity is normally launched by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)` before the test starts, but it is possible to pass a test rule that chooses to launch an Activity on a later time. The Activity is retrieved from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)` by means of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)`, which can be thought of as a getter for the Activity on the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)`. If you use an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)` that launches an Activity on a later time, you should make sure that the Activity is launched by the time or while the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)` is called.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)` wraps around the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)` to make sure the Activity is launched *after* the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)` has completed all necessary steps to control and monitor the compose content.

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 |
|---|---|
| `activityRule: R` | Test rule to use to launch the Activity. |
| `activityProvider: (R) -> A` | Function to retrieve the Activity from the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.Function1)`. |

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

### AndroidComposeTestRule

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

```
fun <R : TestRule, A : ComponentActivity> AndroidComposeTestRule(
    activityRule: R,
    config: ComposeUiTestConfig,
    activityProvider: (R) -> A
): AndroidComposeTestRule<R, A>
```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, where compose content is hosted by an Activity.

The Activity is normally launched by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)` before the test starts, but it is possible to pass a test rule that chooses to launch an Activity on a later time. The Activity is retrieved from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)` by means of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)`, which can be thought of as a getter for the Activity on the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)`. If you use an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)` that launches an Activity on a later time, you should make sure that the Activity is launched by the time or while the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)` is called.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)` wraps around the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)` to make sure the Activity is launched *after* the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)` has completed all necessary steps to control and monitor the compose content.

| Parameters |
|---|---|
| `activityRule: R` | Test rule to use to launch the Activity. |
| `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. |
| `activityProvider: (R) -> A` | Function to retrieve the Activity from the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,androidx.compose.ui.test.ComposeUiTestConfig,kotlin.Function1)`. |

### AndroidComposeTestRule

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

```
fun <R : TestRule, A : ComponentActivity> [AndroidComposeTestRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1))(
    activityRule: R,
    effectContext: CoroutineContext = EmptyCoroutineContext,
    activityProvider: (R) -> A
): AndroidComposeTestRule<R, A>
```

> [!CAUTION]
> **This function is deprecated.**   
> Use AndroidComposeTestRule(activityRule: R, config: ComposeUiTestConfig, activityProvider: (R) -\> A) instead. The \`effectContext\` parameter has been moved into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: AndroidComposeTestRule(activityRule, effectContext, activityProvider) After: AndroidComposeTestRule(activityRule, ComposeUiTestConfig(effectContext), activityProvider), use this instead:
>
> ```kotlin
> AndroidComposeTestRule(activityRule, ComposeUiTestConfig(effectContext), activityProvider)
> ```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)`, where compose content is hosted by an Activity.

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.

The Activity is normally launched by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)` before the test starts, but it is possible to pass a test rule that chooses to launch an Activity on a later time. The Activity is retrieved from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)` by means of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)`, which can be thought of as a getter for the Activity on the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)`. If you use an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)` that launches an Activity on a later time, you should make sure that the Activity is launched by the time or while the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)` is called.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)` wraps around the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)` to make sure the Activity is launched *after* the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)` has completed all necessary steps to control and monitor the compose content.

| Parameters |
|---|---|
| `activityRule: R` | Test rule to use to launch the Activity. |
| `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` or `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scheduler/index.html` (in that order), it will be used for composition and the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MainTestClock`. |
| `activityProvider: (R) -> A` | Function to retrieve the Activity from the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#AndroidComposeTestRule(org.junit.rules.TestRule,kotlin.coroutines.CoroutineContext,kotlin.Function1)`. |

### createAndroidComposeRule

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

```
inline fun <A : ComponentActivity> createAndroidComposeRule(): AndroidComposeTestRule<ActivityScenarioRule<A>, A>
```

Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given activity class type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule()`.

This method is useful for tests that require a custom Activity. This is usually the case for tests where the compose content is set by that Activity, instead of via the test rule's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)`. Make sure that you add the provided activity into your app's manifest file (usually in main/AndroidManifest.xml).

This creates a test rule that is using `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule` as the activity launcher. If you would like to use a different one you can create `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` directly and supply it with your own launcher.

If your test doesn't require a specific Activity, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)` instead.

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`.

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

### createAndroidComposeRule

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

```
fun <A : ComponentActivity> createAndroidComposeRule(activityClass: Class<A>): AndroidComposeTestRule<ActivityScenarioRule<A>, A>
```

Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class)`.

This method is useful for tests that require a custom Activity. This is usually the case for tests where the compose content is set by that Activity, instead of via the test rule's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)`. Make sure that you add the provided activity into your app's manifest file (usually in main/AndroidManifest.xml).

This creates a test rule that is using `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule` as the activity launcher. If you would like to use a different one you can create `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` directly and supply it with your own launcher.

If your test doesn't require a specific Activity, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)` instead.

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 |
|---|---|
| `activityClass: https://developer.android.com/reference/java/lang/Class.html<A>` | The activity class to use in the activity scenario |

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

### createAndroidComposeRule

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

```
inline fun <A : ComponentActivity> createAndroidComposeRule(
    config: ComposeUiTestConfig
): AndroidComposeTestRule<ActivityScenarioRule<A>, A>
```

Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given activity class type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(androidx.compose.ui.test.ComposeUiTestConfig)`.

This method is useful for tests that require a custom Activity. This is usually the case for tests where the compose content is set by that Activity, instead of via the test rule's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)`. Make sure that you add the provided activity into your app's manifest file (usually in main/AndroidManifest.xml).

This creates a test rule that is using `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule` as the activity launcher. If you would like to use a different one you can create `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` directly and supply it with your own launcher.

If your test doesn't require a specific Activity, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)` instead.

| 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. |

### createAndroidComposeRule

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

```
inline fun <A : ComponentActivity> [createAndroidComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(kotlin.coroutines.CoroutineContext))(
    effectContext: CoroutineContext = EmptyCoroutineContext
): AndroidComposeTestRule<ActivityScenarioRule<A>, A>
```

> [!CAUTION]
> **This function is deprecated.**   
> Use createAndroidComposeRule\<A\>(config: ComposeUiTestConfig) instead. The \`effectContext\` parameter has been moved into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: createAndroidComposeRule\<Activity\>(effectContext) After: createAndroidComposeRule\<Activity\>(ComposeUiTestConfig(effectContext)), use this instead:
>
> ```kotlin
> createAndroidComposeRule<A>(ComposeUiTestConfig(effectContext))
> ```

Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, for a given activity class type `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(kotlin.coroutines.CoroutineContext)`.

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 method is useful for tests that require a custom Activity. This is usually the case for tests where the compose content is set by that Activity, instead of via the test rule's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)`. Make sure that you add the provided activity into your app's manifest file (usually in main/AndroidManifest.xml).

This creates a test rule that is using `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule` as the activity launcher. If you would like to use a different one you can create `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` directly and supply it with your own launcher.

If your test doesn't require a specific Activity, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)` instead.

| Parameters |
|---|---|
| `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/junit4/v2/package-summary#createAndroidComposeRule(kotlin.coroutines.CoroutineContext)` if one is present. |

### createAndroidComposeRule

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

```
fun <A : ComponentActivity> createAndroidComposeRule(
    activityClass: Class<A>,
    config: ComposeUiTestConfig
): AndroidComposeTestRule<ActivityScenarioRule<A>, A>
```

Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, configured via a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, for a given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class,androidx.compose.ui.test.ComposeUiTestConfig)`.

This method is useful for tests that require a custom Activity. This is usually the case for tests where the compose content is set by that Activity, instead of via the test rule's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)`. Make sure that you add the provided activity into your app's manifest file (usually in main/AndroidManifest.xml).

This creates a test rule that is using `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule` as the activity launcher. If you would like to use a different one you can create `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` directly and supply it with your own launcher.

If your test doesn't require a specific Activity, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)` instead.

| Parameters |
|---|---|
| `activityClass: https://developer.android.com/reference/java/lang/Class.html<A>` | The activity class to use in the activity scenario |
| `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. |

### createAndroidComposeRule

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

```
fun <A : ComponentActivity> [createAndroidComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class,kotlin.coroutines.CoroutineContext))(
    activityClass: Class<A>,
    effectContext: CoroutineContext = EmptyCoroutineContext
): AndroidComposeTestRule<ActivityScenarioRule<A>, A>
```

> [!CAUTION]
> **This function is deprecated.**   
> Use createAndroidComposeRule(activityClass: Class\<A\>, config: ComposeUiTestConfig) instead. The \`effectContext\` parameter has been moved into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: createAndroidComposeRule(activityClass, effectContext) After: createAndroidComposeRule(activityClass, ComposeUiTestConfig(effectContext)), use this instead:
>
> ```kotlin
> createAndroidComposeRule(activityClass, ComposeUiTestConfig(effectContext))
> ```

Factory method to provide android specific implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)`, for a given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class,kotlin.coroutines.CoroutineContext)`.

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 method is useful for tests that require a custom Activity. This is usually the case for tests where the compose content is set by that Activity, instead of via the test rule's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)`. Make sure that you add the provided activity into your app's manifest file (usually in main/AndroidManifest.xml).

This creates a test rule that is using `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/ActivityScenarioRule` as the activity launcher. If you would like to use a different one you can create `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/AndroidComposeTestRule` directly and supply it with your own launcher.

If your test doesn't require a specific Activity, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)` instead.

| Parameters |
|---|---|
| `activityClass: https://developer.android.com/reference/java/lang/Class.html<A>` | The activity class to use in the activity scenario |
| `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/junit4/v2/package-summary#createAndroidComposeRule(java.lang.Class,kotlin.coroutines.CoroutineContext)` if one is present. |

### createComposeRule

android [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/junit4/v2/+function:createComposeRule)

```
fun createComposeRule(): ComposeContentTestRule
```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule`.

This method is useful for tests in compose libraries where it is irrelevant where the compose content is hosted (e.g. an Activity on Android). Such tests typically set compose content themselves via `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)` and only instrument and assert that content.

For Android this will use the default Activity (android.app.Activity). You need to add a reference to this activity into the manifest file of the corresponding tests (usually in androidTest/AndroidManifest.xml). If your Android test requires a specific Activity to be launched, see `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(kotlin.coroutines.CoroutineContext)`.

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`.

### createComposeRule

android [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/junit4/v2/+function:createComposeRule)

```
fun createComposeRule(config: ComposeUiTestConfig): ComposeContentTestRule
```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule`.

This method is useful for tests in compose libraries where it is irrelevant where the compose content is hosted (e.g. an Activity on Android). Such tests typically set compose content themselves via `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)` and only instrument and assert that content.

For Android this will use the default Activity (android.app.Activity). You need to add a reference to this activity into the manifest file of the corresponding tests (usually in androidTest/AndroidManifest.xml). If your Android test requires a specific Activity to be launched, see `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(kotlin.coroutines.CoroutineContext)`.

| 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. |

### createComposeRule

android [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/junit4/v2/+function:createComposeRule)

```
fun [createComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext))(effectContext: CoroutineContext): ComposeContentTestRule
```

> [!CAUTION]
> **This function is deprecated.**   
> Use createComposeRule(config: ComposeUiTestConfig) instead. The \`effectContext\` parameter has been moved into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: createComposeRule(effectContext) After: createComposeRule(ComposeUiTestConfig(effectContext)), use this instead:
>
> ```kotlin
> createComposeRule(ComposeUiTestConfig(effectContext))
> ```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule`.

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 method is useful for tests in compose libraries where it is irrelevant where the compose content is hosted (e.g. an Activity on Android). Such tests typically set compose content themselves via `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeContentTestRule#setContent(kotlin.Function0)` and only instrument and assert that content.

For Android this will use the default Activity (android.app.Activity). You need to add a reference to this activity into the manifest file of the corresponding tests (usually in androidTest/AndroidManifest.xml). If your Android test requires a specific Activity to be launched, see `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createAndroidComposeRule(kotlin.coroutines.CoroutineContext)`.

| Parameters |
|---|---|
| `effectContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` | 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/junit4/v2/package-summary#createComposeRule(kotlin.coroutines.CoroutineContext)` if one is present. |

### createEmptyComposeRule

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

```
fun createEmptyComposeRule(): ComposeTestRule
```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, that doesn't create a compose host for you in which you can set content.

This method is useful for tests that need to create their own compose host during the test. The returned test rule will not create a host, and consequently does not provide a `setContent` method. To set content in tests using this rule, use the appropriate `setContent` methods from your compose host.

A typical use case on Android is when the test needs to launch an Activity (the compose host) after one or more dependencies have been injected.

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`.

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

### createEmptyComposeRule

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

```
fun createEmptyComposeRule(config: ComposeUiTestConfig): ComposeTestRule
```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule`, configured via an `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ComposeUiTestConfig`, that doesn't create a compose host for you in which you can set content.

This method is useful for tests that need to create their own compose host during the test. The returned test rule will not create a host, and consequently does not provide a `setContent` method. To set content in tests using this rule, use the appropriate `setContent` methods from your compose host.

A typical use case on Android is when the test needs to launch an Activity (the compose host) after one or more dependencies have been injected.

| 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. |

### createEmptyComposeRule

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

```
fun [createEmptyComposeRule](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/v2/package-summary#createEmptyComposeRule(kotlin.coroutines.CoroutineContext))(
    effectContext: CoroutineContext = EmptyCoroutineContext
): ComposeTestRule
```

> [!CAUTION]
> **This function is deprecated.**   
> Use createEmptyComposeRule(config: ComposeUiTestConfig) instead. The \`effectContext\` parameter has been moved into \[ComposeUiTestConfig\] to allow for more flexible test environment configuration. Before: createEmptyComposeRule(effectContext) After: createEmptyComposeRule(ComposeUiTestConfig(effectContext)), use this instead:
>
> ```kotlin
> createEmptyComposeRule(ComposeUiTestConfig(effectContext))
> ```

Factory method to provide an implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/junit4/ComposeTestRule` that doesn't create a compose host for you in which you can set content.

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 method is useful for tests that need to create their own compose host during the test. The returned test rule will not create a host, and consequently does not provide a `setContent` method. To set content in tests using this rule, use the appropriate `setContent` methods from your compose host.

A typical use case on Android is when the test needs to launch an Activity (the compose host) after one or more dependencies have been injected.

| Parameters |
|---|---|
| `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/junit4/v2/package-summary#createEmptyComposeRule(kotlin.coroutines.CoroutineContext)` if one is present. |