接口 ResultMatcher


  • public interface ResultMatcher
    A ResultMatcher matches the result of an executed request against some expectation.

    See static factory methods in MockMvcResultMatchers.

    Example Using Status and Content Result Matchers

     import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
     import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
     import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
    
     // ...
    
     WebApplicationContext wac = ...;
    
     MockMvc mockMvc = webAppContextSetup(wac).build();
    
     mockMvc.perform(get("/form"))
       .andExpect(status().isOk())
       .andExpect(content().mimeType(MediaType.APPLICATION_JSON));
     
    从以下版本开始:
    3.2
    作者:
    Rossen Stoyanchev, Sam Brannen
    • 方法详细资料

      • match

        void match​(MvcResult result)
            throws Exception
        Assert the result of an executed request.
        参数:
        result - the result of the executed request
        抛出:
        Exception - if a failure occurs