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

  • [x] Ensure that default ResultHandlers are applied before default ResultMatchers.