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.
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
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
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
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
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
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
public val boundsAssertionTolerance: Dp
The default Dp tolerance used for bounds assertions (such as assertWidthIsEqualTo, assertHeightIsEqualTo, and assertPositionInRootIsEqualTo). Defaults to Dp.Unspecified.