Espresso & Progress bar Dialog: The epic conflict

If you are trying to test your app that has a ProgressDialog in it, STOP RIGHT THERE! You are gonna be in a world of pain, when your tests keep failing for no apparent reason after failing to find the progressDialog that is vividly visible on the screen.

The problem isn't in your code. It's the shortcoming of the Espresso Testing Framework. The framework can't really handle the animations of the progress dialog. I am still digging around the exact reason, however from the little bit of research I have figured out that the drawable animation of the circle gives the impression of non idle state to the Espresso framework. So what does it mean? It means Espresso keeps waiting for the app to enter the idle state and as long as the progress dialog is visible on the screen, the app stays in the busy state. By the time animation ends, the progress dialog is gone.

When the app enters the idle state and espresso comes out of the waiting loop to start running tests, it fails toexecutes the test command for the progress dialog as there is no progress dialog on the screen now.

So now you might be saying enough with this useless banter. How about telling the solution about this problem?

The answer is simple, DON'T use ProgressDialog. But sometimes you have gotta use them. So the workaround is, use an AlertDialog instead for testing purposes.

Define the BuildConfig for testing purposes, I use DEBUG config for running espresso tests and show alert dialog box in debug config. In release config you can show the ProgressDialog since you won't be running the espresso tests in release config. This resolves the failing test issue and makes sure your UI is working perfectly as well.

Comments

  1. """I just want to say that your article is just as great. The clarity of your message is simple
    excellent and I can assume that you are an expert on this matter.""
    octoplus lg tool crack
    octopus box lg software crack
    octopus crack without box download"

    ReplyDelete

Post a Comment

Popular posts from this blog

Noir A8: Battery Friendly Jelly Bean Rom

ICS Themed Rom For Noir A2

Exploring Redux in React Native: Building a Test App with Example Code