IdlingResource


Represents a resource of an application under test which can cause asynchronous background work to happen during test execution (e.g. an http request in response to a button click).

By default, all interactions from the test with the compose tree (finding nodes, performing gestures, making assertions) will be synchronized with pending work in Compose's internals (such as applying state changes, recomposing, measuring, etc). This ensures that the UI is in a stable state when the interactions are performed, so that e.g. no pending recompositions are still scheduled that could potentially change the UI. However, any asynchronous work that is not done through one of Compose's mechanisms won't be included in the default synchronization. For such work, test authors can create an IdlingResource and register it into the test with androidx.compose.ui.test.junit4.ComposeTestRule .registerIdlingResource, and the interaction will wait for that resource to become idle prior to performing it.

Summary

Public functions

open String?

Returns diagnostics that explain why the idling resource is busy, or null if the resource is not busy.

Cmn

Public properties

Boolean

Whether or not the IdlingResource is idle when reading this value.

Cmn

Public functions

getDiagnosticMessageIfBusy

open fun getDiagnosticMessageIfBusy(): String?

Returns diagnostics that explain why the idling resource is busy, or null if the resource is not busy. Default implementation returns null.

Public properties

isIdleNow

val isIdleNowBoolean

Whether or not the IdlingResource is idle when reading this value. This should always be called from the main thread, which is why it should be lightweight and fast.

If one idling resource returns false, the synchronization system will keep polling all idling resources until they are all idle.