You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to test my clients timeout behavior. To have a deterministic test which also runs as fast as possible I decided to use the kotlinx.coroutines test dispatcher which comes with a virtual clock. It seems that the ktor's HttpTimeoutPlugin does not respect the virtual clock of kotlinx coroutines. Is there an alternative way to test this or should the HttpTimeoutPlugin respect the timing behavior of kotlinx.coroutines?
runTest {
val mutex =Mutex(locked =true)
val mockEngine =MockEngine {
mutex.withLock {
respond("OK")
}
}
val client =HttpClient(mockEngine) {
install(HttpTimeout) {
requestTimeoutMillis =100
}
}
launch {
delay(200)
mutex.unlock()
}
// Assertion error since no exception is thrown// Test is green when no coroutine test scope is used
assertThrows<HttpRequestTimeoutException> {
client.get("/")
}
}
The text was updated successfully, but these errors were encountered:
I want to test my clients timeout behavior. To have a deterministic test which also runs as fast as possible I decided to use the kotlinx.coroutines test dispatcher which comes with a virtual clock. It seems that the ktor's HttpTimeoutPlugin does not respect the virtual clock of kotlinx coroutines. Is there an alternative way to test this or should the HttpTimeoutPlugin respect the timing behavior of kotlinx.coroutines?
The text was updated successfully, but these errors were encountered: