I encountered a fun problem today… My Espresso tests started hanging after I added a ProgressDialog into my layout that was visible when the Activity started.
This was the error in the logs:
It was only happening on devices running Lollipop (Android 5.0, 5.1) or higher. So Marshmallow (6.0) and Nougat (7.0) as well.
Apparently the indeterminate ProgressBar animation causes Espresso to think things are still happening. And it just waits. And waits. Until it gets killed after 45 seconds. Great. This happens even though animations are turned off in the developer options.
There were a couple of workarounds I found on the internet, but I felt they had their own issues so I’ve come up with my own.
Just replace uses of ProgressDialog with TestableIndeterminateProgressBar from this gist (and make sure you have animations disabled in the developer options, which of course you’re already doing).