Skip to content

Most visited

Recently visited


Espresso idling resource

The centerpiece of Espresso is its ability to seamlessly synchronize all test operations with the application being tested. By default, Espresso waits for UI events in the current message queue to be handled and for default instances of AsyncTask to complete before it moves on to the next test operation.

However, there are instances where applications perform background operations, such as communicating with web services, using non-standard means, such as direct creation and management of threads.

In such cases, you have to use idling resources to inform Espresso of the app’s long-running operations.

Creating and registering idling resources

You can implement the IdlingResource interface yourself or use an already-existing implementation, such as CountingIdlingResource, included in the espresso-idling-resource package.

This interface needs to be exposed to the test or created within it and injected into the application. Then, register one or more of your idling resources with Espresso by calling Espresso.registerIdlingResource() in the test setup.

Check out the Espresso idling resource sample.

Implementing idling resources

There are two common ways to implement idling resources:

Note that there are idling resource implementations for popular libraries, such as okhttp-idling-resource.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)