how do you test endpoints that return status codes...
# ktor
s
how do you test endpoints that return status codes like
NotFound
or
BadRequest
since they throw
io.ktor.client.plugins.ClientRequestException
? so this below doesn't work, only way is to do the checks on the exception's message it seems
Copy code
val response = client.get("api/v1/words/x")
response shouldHaveStatus HttpStatusCode.BadRequest
response.bodyAsText() shouldBe INVALID_ID
replace e.g. `NotFound`with
NoContent
?
a
You can disable default response validation by assigning the value
false
to the
expectSuccess
property in the client’s configuration to test them without an exception.
s
oh great, ty