tezvyn:

How would you implement and register a custom IdlingResource?

Source: developer.android.comadvanced

WHAT IT TESTS: Whether you know Espresso's async contract. ANSWER OUTLINE: Implement the three IdlingResource methods with an atomic counter; register via IdlingRegistry in setup and unregister in teardown. RED FLAG: Suggesting Thread.sleep or polling loops.

WHAT IT TESTS: Whether you deeply understand Espresso's synchronization model and can bridge background work to UI test idleness without sleeps. ANSWER OUTLINE: First, implement IdlingResource with getName, isIdleNow reading an atomic counter, and the callback on completion. Second, instrument the background task so it increments on start and decrements on finish. Third, register via IdlingRegistry in @Before and unregister in @After. RED FLAG: Using Thread.sleep, fixed delays, or wrapping the whole app instead of scoping to the specific task.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

How would you implement and register a custom IdlingResource? · Tezvyn