phldavies
03/28/2022, 10:36 AMtestApplication block, I’m trying to test some lifecycle hooks for a custom plugin. Is there a nice way to ensure the application environment is started than making a client call? I currently have something like this:
private suspend fun ApplicationTestBuilder.ensureStarted() = client.get("/") { expectSuccess = false }
class MyTest : FunSpec({
test("plugin works correctly") {
testApplication {
install(MyCustomPlugin) { ... }
ensureStarted()
// test the plugin
}
}
})Aleksei Tirman [JB]
03/28/2022, 10:42 AMphldavies
03/28/2022, 10:46 AMJob on ApplicationStarted event, which won’t fire until the application environment is started. With the testApplication construct, there’s no way to explicitly start the application beyond as a side effect of the first call through the provided (or a constructed) client . I need to test that the Job starts and operates correctly.Aleksei Tirman [JB]
03/28/2022, 10:47 AMphldavies
03/28/2022, 10:49 AMAleksei Tirman [JB]
03/28/2022, 11:03 AMphldavies
03/28/2022, 11:04 AMTestApplication builder and manually start and stop the application, however this doesn’t allow to accessing the client within the builder, unlike testApplication - which is needed to access any externalServices defined in the test application.Aleksei Tirman [JB]
03/28/2022, 1:57 PM