Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

androidx.compose.ui.test.junit4

Interfaces

ComposeContentTestRule

A ComposeTestRule that allows you to set content without the necessity to provide a host for the content.

ComposeTestRule

A TestRule that allows you to test and control composables and applications using Compose.

Classes

AndroidComposeTestRule

Android specific implementation of ComposeContentTestRule, where compose content is hosted by an Activity.

StateRestorationTester

Helps to test the state restoration for your Composable component.

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 ComposeContentTestRule

ComposeTestRule

Factory method to provide an implementation of ComposeTestRule that doesn't create a compose host for you in which you can set content.

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 tests where the compose content is set by that Activity, instead of via the test rule's setContent. 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 your test doesn't require a specific Activity, use createComposeRule instead.

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 tests where the compose content is set by that Activity, instead of via the test rule's setContent. 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 your test doesn't require a specific Activity, use createComposeRule instead.

createComposeRule

actual fun createComposeRule(): ComposeContentTestRule

createEmptyComposeRule

fun createEmptyComposeRule(): ComposeTestRule

Factory method to provide an implementation of ComposeTestRule that doesn't create a compose host for you in which you can set content.

This method is useful for tests that need to create their own compose host during the test. The returned test rule will not create a host, and consequently does not provide a setContent method. To set content in tests using this rule, use the appropriate setContent methods from your compose host.

A typical use case on Android is when the test needs to launch an Activity (the compose host) after one or more dependencies have been injected.