runAndroidComposeUiTest
Function
Android
@ExperimentalTestApi
inline fun <reified A : ComponentActivity> runAndroidComposeUiTest(
effectContext: CoroutineContext = EmptyCoroutineContext,
runTestContext: CoroutineContext = EmptyCoroutineContext,
testTimeout: Duration = 60.seconds,
noinline block: suspend AndroidComposeUiTest<A>.() -> Unit,
): TestResult
Variant of runComposeUiTest
that allows you to specify which Activity should be launched. Be
aware that if the Activity sets content
during its
launch, you cannot use setContent
on the ComposeUiTest anymore as
this would override the content and can lead to subtle bugs.
Parameters
A | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content |
effectContext | The CoroutineContext used to run the composition. The context for LaunchedEffect s 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 MainTestClock . |
runTestContext | The CoroutineContext used to create the context to run the test block . By default block will run using kotlinx.coroutines.test.StandardTestDispatcher . runTestContext and effectContext must not share TestCoroutineScheduler . |
testTimeout | The Duration within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. |
block | The test function. |
Android
@ExperimentalTestApi
fun <A : ComponentActivity> runAndroidComposeUiTest(
activityClass: Class<A>,
effectContext: CoroutineContext = EmptyCoroutineContext,
runTestContext: CoroutineContext = EmptyCoroutineContext,
testTimeout: Duration = 60.seconds,
block: suspend AndroidComposeUiTest<A>.() -> Unit,
): TestResult
Variant of runComposeUiTest
that allows you to specify which Activity should be launched. Be
aware that if the Activity sets content
during its
launch, you cannot use setContent
on the ComposeUiTest anymore as
this would override the content and can lead to subtle bugs.
Parameters
A | The Activity type to be launched, which typically (but not necessarily) hosts the Compose content |
activityClass | The Class of the Activity type to be launched, corresponding to A . |
effectContext | The CoroutineContext used to run the composition. The context for LaunchedEffect s 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 MainTestClock . |
runTestContext | The CoroutineContext used to create the context to run the test block . By default block will run using kotlinx.coroutines.test.StandardTestDispatcher . runTestContext and effectContext must not share TestCoroutineScheduler . |
testTimeout | The Duration within which the test is expected to complete, otherwise a platform specific timeout exception will be thrown. |
block | The test function. |