0

I'm getting the following error when calling response.shouldHaveHeader . The full message is java.lang.NoSuchMethodError: io.ktor.server.testing.TestApplicationResponse.getHeaders()Lio/ktor/response/ResponseHeaders; at io.kotest.assertions.ktor.TestAppMatchersKt$haveHeader$1.test(testAppMatchers.kt:100) at io.kotest.assertions.ktor.TestAppMatchersKt$haveHeader$1.test(testAppMatchers.kt:97) at io.kotest.matchers.ShouldKt.invokeMatcher(should.kt:43) at io.kotest.matchers.ShouldKt.should(should.kt:38) at io.kotest.assertions.ktor.TestAppMatchersKt.shouldHaveHeader(testAppMatchers.kt:95)

I'm using io.kotest.extensions:kotest-assertions-ktor-jvm:1.0.3 and io.ktor:ktor-server-tests:2.0.3 . Any idea how to fix this error?

Suneel
  • 817
  • 3
  • 10
  • 23

1 Answers1

0

The problem is that the kotest-assertions-ktor library is incompatible with Ktor 2.*.* because it depends on Ktor 1.6.8 (I've migrated your sample project to Ktor 1.6.8 and checked that the test isn't crashed with a runtime error anymore).

Since this library hasn't many matchers and depends on deprecated testing API, I suggest using testApplication API and writing custom matchers if you need them.

Aleksei Tirman
  • 4,658
  • 1
  • 5
  • 24