Skip to content

Allow using MockMvc ResultHandler with MockMvcTester #34931

Open
@odrotbohm

Description

@odrotbohm

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(…);

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: testIssues in the test modulestatus: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions