Pick the fix
An Espresso test sometimes fails because a list hasn't loaded yet. Someone added Thread.sleep(2000). Better fix?
Hint 1 of 1
How can the test know the load finished?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Inject a test dispatcher or register an IdlingResource so Espresso waits for the load
Correct. The test waits exactly as long as the work takes.
Why not the others?
- B Increase the sleep to 5000. Slower and still flaky on slow devices.
- C Retry the test 3 times. Hides the problem.
- D Run the test on a faster emulator. Timing still varies.