I'm having a special case when trying to migrate from ktor 2.x to 3.x. We have a helper class for backend tests and mainly its one function is used a lot. Here's the code for it:
private val customApplicationEnvironment =
applicationEngineEnvironment {
config = testEnvironmentConfig()
log = LoggerFactory.getLogger("ktor.test")
}
fun <R> testApp(test: TestApplicationEngine.() -> R): R {
customApplicationEnvironment.start()
val engine = TestApplicationEngine(customApplicationEnvironment) {}
engine.start()
try {
return engine.test()
} finally {
engine.stop(0L, 0L)
customApplicationEnvironment.stop()
}
}
Otherwise its pretty clear to me, but how can I initialize TestApplicationEngine with ktor 3.x as it needs Application, Events etc?