This Question have no Text answers yet!

espresso test ignores IdlingResouce isIdle() returning false

By : Lanitka
Source: Stackoverflow.com
Question!

There is an IdlingResource, e.g. like this

public class IRWatchlistNamesLoaded implements IdlingResource {

private final static String CLASSNAME = "IRWatchlistNamesLoaded";
private ResourceCallback callback;

public IRWatchlistNamesLoaded () {}

@Override
public String getName() {
    return getClass().getName();
}

@Override
public boolean isIdleNow() {
    if(LMaxApplication.watchlists.getNames() != null && LMaxApplication.watchlists.getNames().size() > 0) {
        callback.onTransitionToIdle();
        CustomLog.print(CustomLog.UI_TEST, CLASSNAME, "isIdleNow = TRUE. size  = " + LMaxApplication.watchlists.getNames().size());
        return true;
    }
    CustomLog.print(CustomLog.UI_TEST, CLASSNAME, "isIdleNow = FALSE. size  = " + LMaxApplication.watchlists.getNames().size());
    return false;
}

@Override
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
    this.callback = resourceCallback;
}

}

And the usage is standard - when I need the resource I call

 watchlistLoadedIR = new IRWatchlistNamesLoaded();
 needToUnregisterWatchlistLoadedIR = true;
 Espresso.registerIdlingResources(watchlistLoadedIR);

What I see in logs is that isIdle() returns false (1 or 2 times), my test keeps going and my resource is not loaded properly, so test fails. Also, need to notice that in some other tests this IdlingResource works and espresso really waits for the resource to be idle. The usage is absolutely the same. Please, maybe somebody has any idea why this could happen?

By : Lanitka


Video about espresso test ignores IdlingResouce isIdle() returning false