Does anyone know why my unit tests testing corouti...
# multiplatform
a
Does anyone know why my unit tests testing coroutine stuff doesn’t actually ever stop running
I’ve done the setup like kampkit
m
maybe you suffer for the same thing here: https://kotlinlang.slack.com/archives/C1CFAFJSK/p1613652205052700 is your android/jvm is fine ?
n
I had an iOS unit test hang recently. I think one of the libraries I was using wasn't using the right version of the coroutines library. I didn't need that library anyway so I removed it and my unit tests started working again.
a
@Mustafa Ozhan no the android one also hangs !
m
👍 1
a
I can check this once I get off work and get back to you 🙏
👌 1
u
If I understand correctly coroutines need scope to run. When the scope goes away it automatically cancels the coroutines. If you launch a never ending coroutines in your test, you can expect that it will never stop. you may need to cancel your coroutines job once your tests finish executing.
Copy code
@Test 
fun test() = runBlocking {
val job = launch {
//your coroutine
}
delay(sometime)
job.cancel()

}