接口 ResultMatcher
public interface ResultMatcher
AResultMatcher
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