Package-level declarations

Types

Link copied to clipboard
class AndroidComposeExtension<A : ComponentActivity> : ComposeExtension, BeforeEachCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, AfterEachCallback, ParameterResolver

A JUnit 5 Extension that allows you to test and control Composables and application using Compose. The functionality of testing Compose is provided by means of the runComposeTest method, which receives a ComposeContext from which the test can be orchestrated. The test will block until the app or composable is idle, to ensure the tests are deterministic.

Link copied to clipboard

A context through which composable blocks can be orchestrated within a ComposeExtension.

Link copied to clipboard
interface ComposeExtension : Extension

A JUnit 5 Extension that allows you to test and control Composables and application using Compose. The functionality of testing Compose is provided by means of the runComposeTest method, which receives a ComposeContext from which the test can be orchestrated. The test will block until the app or composable is idle, to ensure the tests are deterministic.

Link copied to clipboard

Functions

Link copied to clipboard

Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createComposeExtension if your tests require a custom Activity. This is usually the case for tests where the Compose content is set by that Activity, instead of via ComposeContext.setContent, provided through the extension. Make sure that you add the provided Activity to your app's manifest file.

Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createComposeExtension if your tests require a custom Activity. This is usually the case for tests where the Compose content is set by that Activity, instead of via ComposeContext.setContent, provided through the extension. Make sure that you add the provided Activity to your app's manifest file. This variant allows you to provide a custom ActivityScenario which is useful in cases where you may want to launch an activity with a custom intent, for example.

fun <A : ComponentActivity> createAndroidComposeExtension(activityClass: Class<A>, scenarioSupplier: () -> ActivityScenario<A> = { ActivityScenario.launch(activityClass) }): AndroidComposeExtension<A>

Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createComposeExtension if your tests require a custom Activity. This is usually the case for tests where the Compose content is set by that Activity, instead of via ComposeContext.setContent, provided through the extension. Make sure that you add the provided Activity to your app's manifest file. You may also provide an optional ActivityScenario supplier which is useful in cases where you may want to launch an activity with a custom intent,for example.

Link copied to clipboard

Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createAndroidComposeExtension if you don't care about the specific activity class to use under the hood.