Launch Apollo Studio

UI Tests

Apollo Android offers a built-in IdlingResource to help writing UI tests with Espresso. The ApolloIdlingResource will make sure that your tests wait for your GraphQL queries terminate before moving on with testing.

Add the following dependency:



If you have multiple ApolloClients you need to create and register multiple ApolloIdlingResource with different names. Registering several IdlingResources with the same name will crash.

// Register the idlingResource before running your tests (once per client).
val idlingResource = ApolloIdlingResource.create("ApolloIdlingResource", apolloClient)

Most frequently this code is put into a custom TestRunner as below. Please note that you need the ApolloClient instance you use in the app.

class TestRunner : AndroidJUnitRunner() {
    override fun onStart() {
        val idlingResource = ApolloIdlingResource.create ("ApolloIdlingResource", apolloClient);

Edit on GitHub