Hi All, I am new to Ktor so I may be missing somet...
# ktor
d
Hi All, I am new to Ktor so I may be missing something obvious. I am trying to use the testing hostfor my server following the instructions on the Ktor Server Testing> page from the manual. In particular, the last example shows this:
Copy code
fun testPostCustomer() = testApplication {
    val client = createClient {
        install(ContentNegotiation) {
            json()
        }
    }
    val response = <http://client.post|client.post>("/customer") {
        contentType(ContentType.Application.Json)
        setBody(Customer(3, "Jet", "Brains"))
    }
    assertEquals("Customer stored correctly", response.bodyAsText())
    assertEquals(HttpStatusCode.Created, response.status)
}
I find that to be broken, as the closure argument of the test application configures the application builder, and executing the stimuli and the assertions mean that you are running these from your app config code before the app is started. I am not even sure how it ever works, even if sometimes it does. In my case, my app is starting an event pump for external Java API (think TIBCO RV) from the ApplicationStarted event, and this callback is invoked at the end of the test, after all assertions have failed (I found that only after commenting out a lot of code). Raised: https://youtrack.jetbrains.com/issue/KTOR-4773