https://kotlinlang.org logo
Title
j

Jeff Lockhart

07/09/2022, 9:44 PM
Is it possible to somehow access XCTestExpectation in *iosTest*s? Or is there another mechanism for testing async code that calls back on the main thread? iOS tests execute on the main thread, which causes callbacks to deadlock with the test code waiting on it.
I found you can configure the compiler to produce an application for running unit tests in a worker thread with
-trw
. But the issue is that the main dispatch queue isn't started, so code dispatched to the main thread is never run. This is true using either
dispatch_sync(dispatch_get_main_queue())
or coroutines
withContext(Dispatchers.Main)
. I created a YouTrack issue.