Roger Kreienbühl
09/08/2025, 8:27 PMonResponseBruce Hamilton
09/09/2025, 6:44 AMtestApplication and install on the client there and test with the server.
Here's an example from CallIdTest in the Ktor repository:
@Test
fun testCallIdChainingFromCoroutineContext() = testApplication {
val client = createClient {
install(CallId)
}
install(ServerCallId) {
generate { "call-id-1" }
}
routing {
get("/1") {
call.respond(client.get("2").bodyAsText())
}
get("2") {
respondWithCallId()
}
}
val response = client.get("/1").bodyAsText()
assertEquals(response, "call-id-1:call-id-1:call-id-1")
}Aleksei Tirman [JB]
09/09/2025, 7:51 AMtestApplication, the client and the server are connected, so they don't use a real network. Unfortunately, it's not possible to test a plugin in isolation.Roger Kreienbühl
09/09/2025, 8:38 AMtestApplication then.Arjan van Wieringen
09/11/2025, 5:58 AMAleksei Tirman [JB]
09/11/2025, 7:34 AMApplicationCall which depends on other interfaces.Roger Kreienbühl
09/14/2025, 9:42 AMio.ktor:ktor-client-mock to test the client plugin