About the test host: I'm seeing it disregard the c...
# ktor
c
About the test host: I'm seeing it disregard the coroutine-test time-advancing behavior. I have a test host with just:
Copy code
routing {
    get("/ping") {
        println(coroutineContext)
        delay(1000)
        call.respondText("Pong")
    }
}
When I use the test client to call it:
Copy code
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?
Copy code
[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]>
a
You are right. Here is the related issue.
c
I'm not sure I understand that issue, shouldn't the test coroutines library work transparently when the
TestCoroutineScheduler
is in the context? Anyway, thanks for the link, I've subscribed to it.