I found this code in the wild on a github issue, b...
# ktor
b
I found this code in the wild on a github issue, but it isn't clear to me how one would reference the HttpClient that is supposedly passed in.
Copy code
private fun testApplicationWrapper2(testBlock: suspend ApplicationTestBuilder.(HttpClient) -> Unit) {
        testApplication {
            application {
...
What I'm attempting to do... handle custom HttpClient creation at the class level so that each test case need not create it. I have that working using a lateinit var, but was hoping the set up could be done and passed in via the testApplicationWrapper.
Copy code
private fun testApplicationWrapper2(testBlock: suspend ApplicationTestBuilder.(HttpClient) -> Unit) {
    testApplication {
        application {
            configureRouting()
            configureSerialization()
        }
        val client: HttpClient = createClient {
            install(ContentNegotiation) {
                json()
            }
        }

        testBlock(client)
        // usage found at <https://youtrack.jetbrains.com/issue/KTOR-4773>
    }
}
a
So has the
testApplicationWrapper2
method solved your problem?
b
Not for modifying the httpclient, that seems to be getting instantiated every time application test builder is called.