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

Dariusz Kuc

03/07/2023, 8:19 PM
@YentaBot how do I create valid
ApplicationRequest
that I can use for testing? tried using
Copy code
val call = TestApplicationEngine().createCall {
  this.method = <http://HttpMethod.Post|HttpMethod.Post>
  this.setBody(mapper.writeValueAsBytes(mockRequest))
}
but I cannot read the object back using
call.receive<Foo>()
(can only read it as plain text) -> am I missing anything?
👀 1
so it looks like the reason why it doesn't work is that request created by using the above is a client request that still has to be processed by the server (which would include the content negotiation plugin) it appears that it is not possible to unit test functionality that relies on
ApplicationRequest
and we are pretty much stuck with integration tests....