From what I understood, `runBlocking` is not avail...
# kotlin-native
n
From what I understood,
runBlocking
is not available for iOS, but what’s the proper way to unit test suspend functions on iOS Simulator then?
j
With runBlocking. It should be available. It is not available in common though. I made an expect actual for that:
Copy code
expect fun runSuspendingTest(block: suspend () -> Unit)
Copy code
import kotlinx.coroutines.runBlocking

actual fun runSuspendingTest(block: suspend () -> Unit) = runBlocking { block() }
Usage:
Copy code
@Test
    fun test() = runSuspendingTest {
        // Suspending tests here
    }
n
What I’ve heard from JetBrains team in the context of working with ktor HttpClient:
You can’t use runBlocking with ios client engine for now: the request is scheduled in the main queue.
So yes, it’s available, but not compatible with HttpClient…
j
Ah ok. I don't use it yet so I don't have the answer. Good to know the current limitation!
b
n
I found your code yesterday. It works like 50% of the time for me. Sometimes one of the assertions fails and the tests hang, sometimes it succeeds. I leave it for now at that, but wait for an official solution.