The second Android 11 Developer Preview is now available, test it out and share your feedback.

androidx.ui.test.android

Classes

AndroidComposeTestCaseSetup

AndroidComposeTestRule

Android specific implementation of ComposeTestRule.

Top-level functions summary

AndroidComposeTestRule<T>
AndroidComposeTestRule(disableTransitions: Boolean = false)

Factory method to provide implementation of AndroidComposeTestRule.

ComposeBenchmarkScope<T>
createAndroidComposeBenchmarkRunner(testCaseFactory: () -> T, activity: Activity)

Factory method to provide implementation of ComposeBenchmarkScope.

Unit

Register compose's idling check to Espresso.

Unit

Unregisters resource registered as part of registerComposeWithEspresso.

Top-level functions

AndroidComposeTestRule

inline fun <reified T : Activity> AndroidComposeTestRule(disableTransitions: Boolean = false): AndroidComposeTestRule<T>

Factory method to provide implementation of AndroidComposeTestRule.

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).

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

createAndroidComposeBenchmarkRunner

fun <T : ComposeTestCase> createAndroidComposeBenchmarkRunner(
    testCaseFactory: () -> T,
    activity: Activity
): ComposeBenchmarkScope<T>

Factory method to provide implementation of ComposeBenchmarkScope.

registerComposeWithEspresso

fun registerComposeWithEspresso(): Unit

Register compose's idling check to Espresso.

This makes sure that Espresso is able to wait for any pending changes in Compose. This resource is automatically registered when any compose testing APIs are used including AndroidComposeTestRule. If you for some reasons want to only use Espresso but still have it wait for Compose being idle you can use this function.

unregisterComposeFromEspresso

fun unregisterComposeFromEspresso(): Unit

Unregisters resource registered as part of registerComposeWithEspresso.