You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the report. I don't think you're missing anything, except the reason bit is a bit misleading. It's actually the error message that's available only when HttpServletResponse#sendError(int, String) is called.
We don't offer a direct assertion for that and we need to figure out if we want. In the meantime you can use the following:
assertThat(result.getResponse().getErrorMessage()).isEqualTo("Could not find xyz");
I went ahead and added a mvc.get().uri("/user/42")).hasErrorMessage("error message") assertion for this.
This is not a common use case, but servletResponse.sendError(int, String) is still called by Spring Framework in some features like @ResponseStatus(code = HttpStatus.BAD_REQUEST, reason = "my error message"). While it's referred as "status reason" in this case, this message is not sent on the HTTP response status line but is rather a Servlet error message dedicated to Servlet error pages. I believe hasErrorMessage and the companion Javadoc fits that description.
When using
MockMvc
the status reason phrase can be asserted like this:This cannot be achieved using
MockMvcTester
:Is there something I'm missing?
The text was updated successfully, but these errors were encountered: