Espresso tests not running reliably AppNotIdleException

1,285 views
Skip to first unread message

subodh....@lonelyplanet.com

unread,
Jun 26, 2016, 5:24:12 PM6/26/16
to Android Testing Support Library


I have used Android 2.2 release 4 to generate some espresso test cases. And these test cases run successfully
about 25% of time, rest of the time they fail with following errors:

android.support.test.espresso.AppNotIdleException: Looped for 157 iterations over 60 SECONDS. The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED.
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:580)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:92)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.check(ViewInteraction.java:158)

There have been many posts of stackoverflow and "possible" solutions for this by introducing IdilingResource implementation.

So have tried running my tests thinking this issue of IdilingResource but my run success rate hasn't improved.

Based on this code from github - https://github.com/chiuki/espresso-samples/tree/master/idling-resource-intent-service



private IntentServiceIdlingResource idlingResource;

@Before
public void registerIntentServiceIdlingResource() {
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
idlingResource = new IntentServiceIdlingResource(instrumentation.getTargetContext());
Espresso.registerIdlingResources(idlingResource);
}

@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}

For what its worth I am using latest espresso-core. (2.2.2)

Is no one encountering this issue? Is there solution for this, any pointer would be much appreciated.

-Subodh
Reply all
Reply to author
Forward
0 new messages