CLOVIS
01/27/2024, 6:55 PMrouting {
get("/ping") {
println(coroutineContext)
delay(1000)
call.respondText("Pong")
}
}
When I use the test client to call it:
testTimeSource.measureTime {
client.get("/ping").status.isSuccess() shouldBe true
}
I get a measured duration of 0s
. The test also takes ~1.2s
to complete, so I guess the server route is running completely outside the test scheduler. However, when the server prints its coroutine context, it looks correct to me?
[io.ktor.client.engine.KtorCallContextElement@1a9dab73, CoroutineId(10), RunningInRunTest, kotlinx.coroutines.test.TestCoroutineScheduler@5fb74425, kotlinx.coroutines.test.TestScopeKt$TestScope$$inlined$CoroutineExceptionHandler$1@5477cec1, CoroutineName(request), kotlinx.coroutines.UndispatchedMarker@17c38005, "request#10":UndispatchedCoroutine{Active}@6422300d, <http://Dispatchers.IO]|Dispatchers.IO]>
Aleksei Tirman [JB]
01/29/2024, 8:48 AMCLOVIS
01/29/2024, 8:59 AMTestCoroutineScheduler
is in the context?
Anyway, thanks for the link, I've subscribed to it.