Carolyn Biggar
01/16/2019, 8:08 PMclient.exchange(url, type)
forcing you to specify a type; and for the exception ones we are checking HttpClientResponseException , which doesn't seem to have body available
I'd really like to just call the endpoint as if I was a client, and see the standard http response - where I can then check the response body as well as the status code - rather than this exception. Is there a way to do this, does anyone have any examples?
Here's a simple representation of what our test looks like at the moment
@MicronautTest
class SampleControllerTest {
@Inject
@field:Client( "/")
lateinit var client: RxHttpClient
@Test
fun `should return bad request when no name is passed`() {
val exception = assertThrows<HttpClientResponseException> {
client.toBlocking()
.exchange("/test/hello", String::class.java)
}
assertThat(exception.status, equalTo(HttpStatus.BAD_REQUEST))
//I want to test the response body contains { "errorReason" : "Missing query parameter: name"}
}
}
See this branch for context https://github.com/stottpaul/micronaut-testcase/tree/test-raw-response-body
Any help appreciated, thanks!