5

When working with espresso, I often come to a point where espresso is stuck (e.g. on onView(withId(R.id.somebutton)).perform(click()) ) waiting for all resources idling, which from what I know can be animations, background tasks, runnables in queue, etc. Currently the only message I receive is:

E/TestRunner: androidx.test.espresso.PerformException: Error performing 'single click - At Coordinates: 359, 1291 and precision: 16, 16' on view 'with id: com.example:id/somebutton'.
(...)
Caused by: androidx.test.espresso.AppNotIdleException: Looped for 7 iterations over 60 SECONDS. The following Idle Conditions failed .

The app is very complex, is there anything that can help narrowing down what is causing the espresso to consider the app is not idle?

Daniel Dudek
  • 515
  • 7
  • 17
  • Write the equivalent test using `@UiThreadTest`, and without accessors like `onView()`. Does it get stuck? If not, you learned a valuable lesson about Espresso! View tests should treat View objects like objects - not test them from a different thread – Phlip Mar 27 '20 at 18:23
  • 1
    Does this answer your question? [Espresso testing disable animation](https://stackoverflow.com/questions/43751079/espresso-testing-disable-animation) – Buddy Christ Mar 28 '20 at 23:45
  • @Phlip I'm not sure I understand - how would I do that without using accessors like `onView()`? can you point to any example showing this approach? – Daniel Dudek Apr 17 '20 at 15:31
  • `ma` is a `MainActivity`: `Button commitButton = ma.configureDevicePopupView.findViewById(R.id.commit_button); commitButton.performClick();`. The test just treats the View object as an object; grabs it and calls a method on it. In the same thread. – Phlip Apr 17 '20 at 19:54
  • Hello, dude, i had the same issue and I fix it just waiting my request animation (loading view) finishing. Something like: onView(withId(R.id.id_loadingView)).check(matches(isDisplayed)). We have another approach, a workaround. You can also set a ThreadSleep (thats not good) – Franklin Hirata Feb 12 '21 at 11:37

1 Answers1

0

You can check here https://stackoverflow.com/a/75015717/10856090 To be able to dump the threads that are running when your test fail. Could be useful to narrow down your issue.

Nicolas
  • 114
  • 1
  • 7