Jamie Craane
10/07/2024, 6:22 AMAleksei Tirman [JB]
10/07/2024, 7:16 AMconfigureRouting
method to pass the test client within the testApplication
.Jamie Craane
10/07/2024, 7:28 AMAleksei Tirman [JB]
10/07/2024, 7:29 AMJamie Craane
10/07/2024, 7:45 AMAleksei Tirman [JB]
10/07/2024, 7:47 AMtestApplication
block down to the method that configures the routing.Jamie Craane
10/07/2024, 8:57 AMfun main() {
embeddedServer(CIO, port = 8082, host = "0.0.0.0", module = Application::module)
.start(wait = true)
}
fun Application.module() {
testApplication {
this@module.configureRouting(client)
}
}
I do get an error if I try it like this:
2024-10-07 10:52:08.790 [DefaultDispatcher-worker-9] DEBUG io.ktor.server.Application - Unhandled: GET - /helloService/jamie. Exception class kotlinx.coroutines.JobCancellationException: Parent job is Completed
kotlinx.coroutines.JobCancellationException: Parent job is Completed
Aleksei Tirman [JB]
10/07/2024, 10:40 AMHttpClient
type for the Application.configureRouting
method. Second, when using embeddedServer
, you need to call the configureRouting
method with the HttpClient
instance for the production environment. Within the test, you can pass the test client to the configureRouting
method.Jamie Craane
10/07/2024, 10:56 AMAleksei Tirman [JB]
10/07/2024, 11:40 AMJamie Craane
10/07/2024, 12:42 PM