Interface ResultMatcher
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
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")) .andExpectAll( status().isOk(), content().mimeType(MediaType.APPLICATION_JSON));
- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Sam Brannen
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Assert the result of an executed request.static ResultMatcher
matchAll
(ResultMatcher... matchers) Deprecated.
-
Method Details
-
match
Assert the result of an executed request.- Parameters:
result
- the result of the executed request- Throws:
Exception
- if a failure occurs
-
matchAll
Deprecated.as of Spring Framework 5.3.10, in favor ofResultActions.andExpectAll(ResultMatcher...)
Static method for matching with an array of result matchers.- Parameters:
matchers
- the matchers- Since:
- 5.1
-
ResultActions.andExpectAll(ResultMatcher...)