spring-framework
spring-framework copied to clipboard
Allow using MockMvc `ResultHandler` with `MockMvcTester`
On a standard MockMvc setup, you can register ResultHandler instances on the ResultActions via ….andDo(ResultHandler). Internally, the handler gets called with the MvcResult instance obtained through the request execution. This is the primary mechanism for projects such as Spring REST Docs to hook the API documenting feature into the interactions.
With MockMvcTester, using such a ResultHandler requires a bit more effort:
ResultHandler handler = …;
MvcTestResult result = tester.perform(…);
handler.handle(result.getMvcResult());
assertThat(result).…
Do you think it would be possible to add an equivalent of ….andDo(…) to MockMvcTester so that the call chain could look like this again?
MvcTestResult result = tester.perform(…)
.andDo(…);