Espresso - how to wait for idle without an assertion/view interaction?

Viewed 4459

I would like to simply block the instrumentation (test) thread until Espresso is idle.

fun test(){
    // do some stuff
    Espresso.waitForIdle()
    // do some more stuff once Espresso reports that the application is idle
}

What's the best way to do this?

note: Espresso.waitForIdle() is a method I made up

2 Answers

There is also the following:

InstrumentationRegistry.getInstrumentation().waitForIdle {

}

which run the code inside lambda after it is idle.

Related