Could anyone suggest a way to write a unit test `...
# ktor
j
Could anyone suggest a way to write a unit test
HttpRequestRetry
? I want to
retryOnExceptionIf
cause is
ServerResponseException
. Using
MockEngine.requestHistory
does not seem to account each time a retry request occurs so I was wondering if someone could have a clever idea on how to test this logic.
a
You can use the
HttpSend
plugin to observe the actual sending attempts. Here is an example:
Copy code
val requests = mutableListOf<HttpRequestBuilder>()
client.plugin(HttpSend).intercept { req ->
    requests.add(req)
    execute(builder)
}
j
Thank you, will try this !