Support for idling resource
Hi,
I was just wondering how hard is to implement/expose some sort of mechanism to be able to create idling resources that wait for the coroutines to finish.
I can try sending you a PR if you point me in the right direction on what you think is the best way to do it. I think it'd be a great addition to the library.
Could you share a use case to be more specific?
Hi!
Integration tests with espresso would hugely benefit from this feature. Imagine a UI test that access a database or the network (or just changes the execution thread by using async/await). We will want to wait for those tasks to finish to start verifying that the presented views are in place.
We have a Kotlin exercise that shows how to use Espresso in Kotlin (https://github.com/Karumi/KataSuperHeroesKotlin). In this project, we are avoiding the issue by replacing the slow resource access with a test double but there are many places where that's not possible (there is a lot of legacy code with no DI or similar patterns around). Actually, in this exercise we are using the async/await library and effectively doing a thread change but it returns so fast that the test runs correctly but it can potentially fail in other (slower) environments.
The most straightforward implementation of an IdlingResource in this case would be to implement the isIdleNow(): Boolean method and returning whenever there are no more coroutines being executed. This is the point where, because I don't really know how the library is implemented, I've no idea how hard would it be to implement the feature.
I see, thanks! Could you make a small project to tackle the problem with existing tools and I can take a look how coroutines could help. It sounds like coroutines is a right tool for this.