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
When I test a service that responds with a 4xx status code (e.g. validation error), then MockHttpServletResponse will contain an empty body instead of valid JSON with the error description.
spring-boot-starter-test: 2.2.5.RELEASE
Sample Project: https://github.com/miron4dev/spring-boot-issue-20345/
In DemoControllerIntegrationTest there is an assert that a response body should not be an empty string in case of 4xx error. This assert is failing, because the body is empty.
If you execute the same service manually, you'll get next JSON with the error description:
Thanks for the sample. This is a duplicate of #5574. You may want to test your error responses using a running server and TestRestTemplate or TestWebClient. Alternatively, you may want to explore this approach with the caveat that your test is then not exactly testing what will happen at runtime.
When I test a service that responds with a 4xx status code (e.g. validation error), then MockHttpServletResponse will contain an empty body instead of valid JSON with the error description.
spring-boot-starter-test: 2.2.5.RELEASE
Sample Project: https://github.com/miron4dev/spring-boot-issue-20345/
In
DemoControllerIntegrationTest
there is an assert that a response body should not be an empty string in case of 4xx error. This assert is failing, because the body is empty.If you execute the same service manually, you'll get next JSON with the error description:
The text was updated successfully, but these errors were encountered: