Davide Giuseppe Farella
08/22/2020, 2:12 PMTest finished with active jobs
scope.launch(Io) {
withTimeout(500) {
while (stack.isEmpty()) {
delay(1) // await
}
result.data = stack.removeFirst()
}
}
While this completes successfully
val j = scope.launch(Io) {
while (stack.isEmpty()) {
delay(1) // await
}
result.data = stack.removeFirst()
}
scope.launch {
delay(500)
j.cancel()
}tseisel
08/22/2020, 2:31 PMDavide Giuseppe Farella
08/22/2020, 2:32 PMdelay should be my way out.
I tried with Channel but I had trouble https://github.com/Kotlin/kotlinx.coroutines/issues/2202 and my code was buggy, so I tried to start from basic things for nowtseisel
08/22/2020, 2:48 PMrunBlockingTest has some flaws currently, it is unable to work with alternative dispatchers like <http://Dispatchers.IO|Dispatchers.IO>.
The trick is to inject those `CoroutineDispatcher`s so that you could inject a TestCoroutineDispatcher in tests.Davide Giuseppe Farella
08/22/2020, 2:49 PMIo , not IO 🙂
interface DispatchersProvider {
val Main: CoroutineDispatcher
val Comp: CoroutineDispatcher
val Io: CoroutineDispatcher
}