Skip to content

Apply default ResultHandlers before default ResultMatchers in MockMvc #27225

@sbrannen

Description

@sbrannen

Overview

MockMvc.applyDefaultResultActions(MvcResult) currently applies default ResultMatchers before default ResultHandlers. Consequently, if a ResultMatcher fails, no ResultHandler will be applied.

For example, in the following test, if alwaysExpect(content().string("Boom!")) results in an exception, alwaysDo(print(System.err)) will never be applied, and the user will never see the expected debug output to help diagnose the problem.

@Test
void test() throws Exception {
	standaloneSetup(new SimpleController())
		.alwaysDo(print(System.err))
		.alwaysExpect(content().string("Boom!"))
		.build()
		.perform(get("/"));
}

Deliverables

  • Ensure that default ResultHandlers are applied before default ResultMatchers.

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions