has anyone used Espresso to test Android UX that’s backed by a multiplatform ktor client?
I’m trying to use Espresso to verify that a response is rendered on the screen, my test starts and I call
ktorClient.get<Something>
and see the request logged, but the ktor client gets blocked and the ktor function never returns. As such the test hangs forever.
The application runs fine normally.
Evan
02/02/2021, 12:57 AM
I’ve made sure to wrap the call with a counting idling resource at the view model layer a la Smoothie: https://github.com/coroutineDispatcher/smoothie
The only way I can seem to make the ktor function return is by wrapping it in
runBlocking
but that then blocks the UI / main thread.
j
Jorge R
02/02/2021, 11:22 AM
If you are planning to test this kind of scenario, you better have an architecture that is supporting dependency injection, so you can disconnect from network request calls. Those are introducing a lot of toxicity in tests and it is not worth the effort to do a full end to end testing using Espresso, IMHO.