In the following block of testing code: ``` @Te...
# ktor
m
In the following block of testing code:
Copy code
@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():
Copy code
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 thread
1
a
Can you share simplified definitions of the
configureTestDatabase
and
configureApplication
methods to reproduce the problem?
m
I found the problem. What’s relevant is that inside
configureTestDatabase
, which is inside the application block, I call Exposed’s
Database.connect()
. By moving it outside of the application block, the code runs sequentially.