Mario Andhika
09/30/2024, 6:08 AM@Test
fun testFetchReport() = testApplication {
setup()
println("After setup")
}
The line “After setup” is printed is executed before setup(). What would possibly cause this? Here’s what’s in setup():
fun ApplicationTestBuilder.setup() {
application {
configureApplication()
configureTestDatabase()
}
client.config {
install(io.ktor.client.plugins.resources.Resources)
}
}
Configure test database consists of Exposed configuration and connection. Configure application is for other modules.
Edit: Seems like this is caused by Exposed implicitly initializing in different threadAleksei Tirman [JB]
10/02/2024, 7:56 AMconfigureTestDatabase
and configureApplication
methods to reproduce the problem?Mario Andhika
10/02/2024, 8:28 AMconfigureTestDatabase
, which is inside the application block, I call Exposed’s Database.connect()
. By moving it outside of the application block, the code runs sequentially.