Skip to main content
Version: 5.9


The kotest-assertions-ktor module provides response matchers for a Ktor application. There are matchers for both TestApplicationResponse if you are using the server side test support, and for HttpResponse if you are using the ktor HTTP client.

To add Ktor matchers, add the following dependency to your project


An example of using the matchers with the server side test support:

withTestApplication({ module(testing = true) }) {
handleRequest(HttpMethod.Get, "/").apply {
response shouldHaveStatus HttpStatusCode.OK
response shouldNotHaveContent "failure"
response.shouldHaveHeader(name = "Authorization", value = "Bearer")
response.shouldNotHaveCookie(name = "Set-Cookie", cookieValue = "id=1234")

And an example of using the client support:

val client = HttpClient(CIO)
val response ="")
response.shouldHaveHeader(name = "Authorization", value = "Bearer")