twisterrob
02/15/2020, 3:54 PM[Test worker] ktor.test(ApplicationEngineEnvironmentReloading.kt:135) NoThis is how I use tests (ktor 1.3.1):patterns specified, automatic reload is not activektor.deployment.watch
private fun endpointTest(test: TestApplicationEngine.() -> Unit) {
withTestApplication(
{ /* I apply my `fun Application.module()` setup here */ },
test
)
}
How can I fix that message?withTestApplication
doesn't have the same watchPaths
parameter as embeddedServer
and I can't find another way to set watchPaths
via Application.*
.fun Application.configuration() {
(environment.config as? MapApplicationConfig)?.apply {
if (propertyOrNull("ktor.deployment.watch") === null) {
put(
"ktor.deployment.watch",
"silence 'No ktor.deployment.watch patterns specified' in ApplicationEngineEnvironmentReloading"
)
}
}
but ApplicationEngineEnvironmentReloading
caches the value at construction time (not startup), so this change doesn't propagate.private fun endpointTest(test: TestApplicationEngine.() -> Unit) {
withApplication(
environment = createTestEnvironment {
(config as? MapApplicationConfig)?.apply {
if (propertyOrNull("ktor.deployment.watch") === null) {
put(
"ktor.deployment.watch",
listOf("silence 'No ktor.deployment.watch patterns specified' in ApplicationEngineEnvironmentReloading")
)
}
}
}
) {
/* I apply my `fun Application.module()` setup here */
test()
}
}
but now I'm getting a full classpath listing and
No ktor.deployment.watch patterns match classpath entries, automatic reload is not activeIs there no way to disable reloading?!
ktor.test
logger which means that I would lose all test logging šwithApplication(
environment = createTestEnvironment {
val originalLog = log
log = object : Logger by originalLog {
override fun info(msg: String?) {
when (msg) {
"No ktor.deployment.watch patterns specified, automatic reload is not active" -> Unit
else -> <http://originalLog.info|originalLog.info>(msg)
}
}
}
}
)
christoph.pickl
02/16/2020, 11:41 AM