接口 ResultMatcher
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface 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
方法概要
所有方法 静态方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
match(MvcResult result)
Assert the result of an executed request.static ResultMatcher
matchAll(ResultMatcher... matchers)
Static method for matching with an array of result matchers.
方法详细资料
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
matchAll
static ResultMatcher matchAll(ResultMatcher... matchers)
Static method for matching with an array of result matchers.- 参数:
matchers
- the matchers- 从以下版本开始:
- 5.1