forked from Karumi/KataSuperHeroesAndroid
-
Notifications
You must be signed in to change notification settings - Fork 7
3.1 Idling Resources
David González edited this page Jul 31, 2016
·
5 revisions
Espresso handles concurrency when using AsyncTasks
. If we are using a different model to launch our background tasks, we need to tell Espresso when we are idle. That's when idling resources come handy.
@Before
public void registerIntentServiceIdlingResource() {
idlingResource = new RecyclerViewWithContentIdlingResource(activityRule.getActivity(), R.id.recycler_view, 12);
Espresso.registerIdlingResources(idlingResource);
}
@After
public void unregisterIntentServiceIdlingResource() {
Espresso.unregisterIdlingResources(idlingResource);
}
When using the Mock instance, there is no threading involved. In order to simulate real threading, modify SuperHeroesRepository test double to perform a Thread.sleep
and use the custom idling resources you'll find in this repository to get your tests working.