I came up with one solution, in which i basically ...
# ktor
a
I came up with one solution, in which i basically modified code of MockEngine and MockEngineConfig to keep invocation count which will be accessible within the
invoke
function and then you can something like
Copy code
typealias MockResponse = HttpClientCall.() -> MockHttpResponse

fun mockEngine(responses: Array<out MockResponse>): MockEngineCounting {
    return MockEngineCounting.invoke { invocationCount ->
        if (invocationCount == responses.size) {
            error("Unhandled ${url.fullUrl} on invocationCount=$invocationCount")
        } else {
            responses[invocationCount](call)
        }
    }
}
Is it like the right way to go or there is some better solution?
👌 1
👍 1