Espresso tests hang with android.support.test.espresso.AppNotIdleException on Api Level 21-24

5,311 views
Skip to first unread message

pavel.a...@gmail.com

unread,
Dec 7, 2016, 1:14:13 AM12/7/16
to Android Testing Support Library
Hello all,

I'm a bit uncertain about what's going on here, but I'm repeatedly running into an issue where if I run my instrumentation tests on API 19 or 25, my tests run as expected. If I run my tests on either the native HAXM emulator or Genymotion on API levels 21-24, they stall out with:
Caused by: android.support.test.espresso.AppNotIdleException: Looped for 3359 iterations over 60 SECONDS. The following Idle Conditions failed .

No Idle conditions are provided by the stack trace. I've implemented the TestButler library (https://github.com/linkedin/test-butler) to disable animations and a version of Google's CountingIdlingResource for the purposes of tracking mocked web request.

Here is the relevant portion of the build file:
androidTestCompile 'com.android.support:support-annotations:24.2.1'
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.squareup.okhttp:mockwebserver:2.3.0'
androidTestCompile 'com.linkedin.testbutler:test-butler-library:1.1.0'

Does anyone have any idea about what could be going on or what additional tools I could use to identify what piece of code/setting is causing the idle timeout?

Thanks in advance!

pavel.a...@gmail.com

unread,
Dec 7, 2016, 1:16:34 AM12/7/16
to Android Testing Support Library, pavel.a...@gmail.com
Full stack trace, just in case:

android.support.test.espresso.PerformException: Error performing 'single click - At Coordinates: 719, 804 and precision: 16, 16' on view 'with id: com.tophat.android.app:id/sign_in_button'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:80)
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.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
at com.tophat.android.app.LoginTest.user_can_reset_password(LoginTest.java:210)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at com.tophat.android.app.THInstrumentationTestRunner.onStart(THInstrumentationTestRunner.java:17)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)

Caused by: android.support.test.espresso.AppNotIdleException: Looped for 3359 iterations over 60 SECONDS. The following Idle Conditions failed .
at android.support.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:61)
at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:480)
at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:411)
at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:229)
at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:138)
at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:118)
at android.support.test.espresso.action.Tap.sendSingleTap(Tap.java:135)
at android.support.test.espresso.action.Tap.access$100(Tap.java:35)
at android.support.test.espresso.action.Tap$1.sendTap(Tap.java:40)
at android.support.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:98)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Nick Korostelev

unread,
Dec 7, 2016, 4:26:35 PM12/7/16
to Android Testing Support Library, pavel.a...@gmail.com
Are you sure nothing is holding the main/ui thread? go to Developer Settings and enable "show surface updates" then run the test and observe the device under test for any UI updates... if the screen is constantly flashing then something is constantly updating the UI thread, thus the app is never idle. 

pavel.a...@gmail.com

unread,
Dec 8, 2016, 6:24:25 PM12/8/16
to Android Testing Support Library, pavel.a...@gmail.com
Hi Nick,

Thanks a lot for your suggestion. It appears that there was indeed a hidden progress view running on the main UI thread and preventing the app in that specific Activity from idling. "Show surface updates" was very useful in locating that issue.

Thanks again!

zesh...@gmail.com

unread,
Mar 23, 2017, 3:01:55 AM3/23/17
to Android Testing Support Library, pavel.a...@gmail.com
Goods tips! I'm find something updating the surface.
Message has been deleted

tudor...@gmail.com

unread,
Jan 22, 2019, 9:39:43 AM1/22/19
to Android Testing Support Library
This also helped me. Thanks!

Ceri Dian

unread,
Feb 10, 2021, 8:48:45 PM2/10/21
to Android Testing Support Library
Thank you, this was very helpful!

Jarrad Cutting

unread,
Mar 3, 2022, 4:33:02 PM3/3/22
to Android Testing Support Library
I have a record button that rotates while the user is recording a video. How can I get around this? I would prefer not having to manually disable this animation for testing (as it defeats the purpose of automated testing). I would rather be able to tell Espresso to do something after a period of time rather than waiting for idle.

Rocio dD

unread,
Nov 3, 2022, 5:16:35 AM11/3/22
to Android Testing Support Library
Is there any progress on this matter? I have the same problem with a view that is constantly updating. I want to tell Espresso not wait for idle
Reply all
Reply to author
Forward
0 new messages