Hello, we have a sequence of tests like: ```shoul...
# ktor
a
Hello, we have a sequence of tests like:
Copy code
should("respond OK") {
    testApplication {
        application {
            mockService("11111111111")
            configureServing()
            configureRouting()
        }
        client.get("/v1/foo/XXX00000000123").apply {
            assertEquals(HttpStatusCode.OK, status)
        }
    }
}
should("respond to Unauthorized") {
    testApplication {
        application {
            mockService("12345678")
            configureServing()
            configureRouting()
        }
        client.get("/v1/foo/XXX00000000123").apply {
            assertEquals(HttpStatusCode.Unauthorized, status)
        }
    }
}
and the mockService mock a static builder using mockk
Copy code
private fun mockService(id: String?) {
    mockkObject(ReferenceClientBuilder)
    val fakeService = mockk<ReferenceClient>()
    coEvery { fakeService.customerId(any()) } returns id
    ...
    coEvery { ReferenceClientBuilder.getClient(any()) } returns fakeService
}
Up to ktor 2.1.2 everything was ok, but now with 2.1.3 the second test fails cause the static mockk is just set on the first test and not updated on following ones. Any hints? Thanks!
a
Could you please share a self-contained code for your test to reproduce this problem?
a
Ciao @Aleksei Tirman [JB] we found the cause of the problem. The mock was used by another in-between non-mocked singleton service that for some reasons was rebuilt for every testApplication for 2.1.2 and not on 2.1.3 (I would say correctly). Thanks!