Class

ComposeUiTestConfig

Defines the configuration requirements for a Compose test environment.

Source set: Android
public class ComposeUiTestConfig

Defines the configuration requirements for a Compose test environment.

This configuration allows for fine-grained control over the test execution environment, including the coroutine contexts used for composition and test execution, the overall test timeout, and the initial input mode.

Source set: Common
public class ComposeUiTestConfig(
    effectContext: CoroutineContext = EmptyCoroutineContext,
    runTestContext: CoroutineContext = EmptyCoroutineContext,
    testTimeout: Duration = 60.seconds,
    inputMode: InputMode = InputMode.Touch,
    failurePolicy: TestFailurePolicy = TestFailurePolicy(),
    boundsAssertionTolerance: Dp = Dp.Unspecified,
)

Defines the configuration requirements for a Compose test environment.

This configuration allows for fine-grained control over the test execution environment, including the coroutine contexts used for composition and test execution, the overall test timeout, and the initial input mode.

Parameters

effectContext The CoroutineContext used to run the composition. The context for LaunchedEffects and rememberCoroutineScope will be derived from this context. If this context contains a TestDispatcher or TestCoroutineScheduler (in that order), it will be used for composition and the androidx.compose.ui.test.MainTestClock. Defaults to EmptyCoroutineContext.
runTestContext The CoroutineContext used to create the context to run the test block. By default, test block will run using kotlinx.coroutines.test.StandardTestDispatcher. runTestContext and effectContext must not share TestCoroutineScheduler. Defaults to EmptyCoroutineContext.
testTimeout The Duration within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. Defaults to 60 seconds.
inputMode The InputMode to be used for the test. This determines how input events (such as touch or keyboard) are injected and handled during the test execution. Defaults to InputMode.Touch.
failurePolicy The TestFailurePolicy used to configure the failure handling pipeline, such as capture modes for diagnostic artifacts (screenshots, UI hierarchy) and custom failure handlers. Defaults to TestFailurePolicy.
boundsAssertionTolerance The default Dp tolerance used for bounds assertions (such as assertWidthIsEqualTo, assertHeightIsEqualTo, and assertPositionInRootIsEqualTo). Defaults to Dp.Unspecified.

Properties

effectContext

Source set: Common
public val effectContext: CoroutineContext

The CoroutineContext used to run the composition. The context for LaunchedEffects and rememberCoroutineScope will be derived from this context. If this context contains a TestDispatcher or TestCoroutineScheduler (in that order), it will be used for composition and the androidx.compose.ui.test.MainTestClock. Defaults to EmptyCoroutineContext.

runTestContext

Source set: Common
public val runTestContext: CoroutineContext

The CoroutineContext used to create the context to run the test block. By default, test block will run using kotlinx.coroutines.test.StandardTestDispatcher. runTestContext and effectContext must not share TestCoroutineScheduler. Defaults to EmptyCoroutineContext.

testTimeout

Source set: Common
public val testTimeout: Duration

The Duration within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. Defaults to 60 seconds.

inputMode

Source set: Common
public val inputMode: InputMode

The InputMode to be used for the test. This determines how input events (such as touch or keyboard) are injected and handled during the test execution. Defaults to InputMode.Touch.

failurePolicy

Source set: Common
public val failurePolicy: TestFailurePolicy

The TestFailurePolicy used to configure the failure handling pipeline, such as capture modes for diagnostic artifacts (screenshots, UI hierarchy) and custom failure handlers. Defaults to TestFailurePolicy.

boundsAssertionTolerance

Source set: Common
public val boundsAssertionTolerance: Dp

The default Dp tolerance used for bounds assertions (such as assertWidthIsEqualTo, assertHeightIsEqualTo, and assertPositionInRootIsEqualTo). Defaults to Dp.Unspecified.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: