Open francos opened 6 years ago
just a wild a** guess, but perhaps InstrumentationRegistry.getInstrumentation().runOnMainSync { } would help? Or better yet, externalising executor/thread pools and providing them to doAsync?
Thanks for the answer @Ant8. In the end, I ended up moving to coroutines as I thought it was interesting to learn how to use them. I still had this issue in a different way (when using the UI
constant that is used to run a coroutine on the main thread), so I created some custom code to use my own constant instead of UI
so that I could override it in tests.
I hope your answer can help other people that are having this issue!
I'm creating some unit tests for my Android app logic and I'm stuck trying to figure out how to make
uiThread()
work in them.The code I have is very basic:
and the error I'm getting is:
Any idea how I can make this work?