https://kotlinlang.org logo
#ktor
Title
# ktor
t

tieskedh

10/21/2020, 10:45 AM
Maybe a very easy question, but I couldn't find it: I want to create a test in Ktor-client that simulates that the httpClient does not have an connection. How can I do that?
k

KamilH

10/21/2020, 10:59 AM
You can use
MockEngine
like that:
Copy code
HttpClient(MockEngine) {
    engine {
        addHandler {
            throw IOException("")
        }
    }
}
👍🏻 1
t

tieskedh

10/21/2020, 11:01 AM
haha, thank! I was indeed thinking way to complicated...