How to use espresso idling resource if long running task is started in Activity's onCreate ?
I have created a custom IdlingResource and it is working fine if the long async method call is triggered by click event, but breaks whenever the it is called in Acitivty's onCreate method.
Example:
public void onBtnClick(){
setIdle(true); // This works fine, our tests wait until setIdle(false) is called
doSomeBackgroundTask();
}
public void onDone(){
setResourceIdle(false);
setIdle(false);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setIdle(true); // This doesn't work, our tests won't wait
doSomeBackgroundTask();
}
Any ideas to overcome this situation?