admin管理员组文章数量:1400007
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?
本文标签: kotlinTest refactoring when migrating ktor 2x to 3xStack Overflow
版权声明:本文标题:kotlin - Test refactoring when migrating ktor 2.x to 3.x - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744206943a2595234.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论