https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Abhishek Dewan

02/22/2021, 4:24 AM
Does anyone know why my unit tests testing coroutine stuff doesn’t actually ever stop running
I’ve done the setup like kampkit
m

Mustafa Ozhan

02/22/2021, 8:22 AM
maybe you suffer for the same thing here: https://kotlinlang.slack.com/archives/C1CFAFJSK/p1613652205052700 is your android/jvm is fine ?
n

Neal Sanche

02/22/2021, 3:09 PM
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

Abhishek Dewan

02/22/2021, 3:54 PM
@Mustafa Ozhan no the android one also hangs !
m

Mustafa Ozhan

02/22/2021, 5:04 PM
👍 1
a

Abhishek Dewan

02/22/2021, 5:05 PM
I can check this once I get off work and get back to you 🙏
👌 1
u

Umit AYDIN

02/23/2021, 5:57 AM
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()

}
3 Views