I am trying to run an Espresso test under real conditions in my app. Problem is that tests never run because Espresso cannot detect an idle state in order to inject it's event to queue. Therefore it hangs and ends with known ASYNC_TASKS_HAVE_IDLED error.
Why this happens?
The application is using SignalR library and it is initialized on app start. "Library GitHub url". This library creates multiple long polling connections in order to send and receive all kind of messages and events to/from the server.
These connections are implemented with AsyncTask (class url) and since they end rarely (and when they do, they are restarted instantly), Espresso has very little chance to detect idle state and continue the execution.
So, is there some workaround for this problem? Am I really forced to switch to UIAutomator because of this?
Notes:
- Disabling the SignalR is not an option (tried, tests work but then I'm missing the point of the app)
- Mocking the SignalR is also not an option. I want to test the real data.
Thank you for your time.