Google is committed to advancing racial equity for Black communities. See how.

androidx.compose.ui.test.junit4

Interfaces

AnimationClockTestRule

ComposeTestRule

Enables to run tests of individual composables without having to do manual setup.

Classes

AndroidComposeTestRule

Android specific implementation of ComposeTestRule.

DisableTransitionsTestRule

This rule will disable all transition animations for the test.

StateRestorationTester

Helps to test the state restoration for your Composable component.

Type-aliases

DisableTransitions

Top-level functions summary

AndroidComposeTestRule<ActivityScenarioRule<A>, A>

Factory method to provide android specific implementation of createComposeRule, for a given activity class type A.

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

Factory method to provide android specific implementation of createComposeRule, for a given activityClass.

actual AnimationClockTestRule

actual ComposeTestRule

Top-level functions

createAndroidComposeRule

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

Factory method to provide android specific implementation of createComposeRule, for a given activity class type A.

This method is useful for tests that require a custom Activity. This is usually the case for app tests. 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 ActivityScenarioRule as the activity launcher. If you would like to use a different one you can create AndroidComposeTestRule directly and supply it with your own launcher.

If you don't care about specific activity and just want to test composables in general, see createComposeRule.

createAndroidComposeRule

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

Factory method to provide android specific implementation of createComposeRule, for a given activityClass.

This method is useful for tests that require a custom Activity. This is usually the case for app tests. 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 ActivityScenarioRule as the activity launcher. If you would like to use a different one you can create AndroidComposeTestRule directly and supply it with your own launcher.

If you don't care about specific activity and just want to test composables in general, see createComposeRule.

createAnimationClockRule

actual fun createAnimationClockRule(): AnimationClockTestRule

Deprecated.

createComposeRule

actual fun createComposeRule(): ComposeTestRule