Open tveon opened 4 years ago
And I found the problem - this block:
response.bodyHandler { body ->
//FIXME - this does not get verified!
assertEquals("Hello from Vert.x!", body.toString(StandardCharsets.UTF_8))
}
should be
response.bodyHandler { body ->
testContext.verify {
assertEquals("Hello from Vert.x!", body.toString(StandardCharsets.UTF_8))
}
}
pretty obvious when you know it...
BTW - I didn’t close the issue, as I think the documentation/examples needs to be updated - preferably to not also include other libs like the webclient or vertx-unit
Sure, please do not hesitate to offer pull-requests to improve the docs/examples!
BTW to test HTTP bodies it's easier to use the vertx-web-client
as you can more easily extract text / json.
This might be a trivial mistake on my side, but I have not been able to find any guide or documentation on the proper way to assert the body of an HTTP response.
My server is basically what you get from the starter:
And the test-class:
Notice the missing
\n
in theassertEquals
.When running the test, I see the following output:
So - what is the correct way to verify the body of the response?
Versions: