diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/ResultActions.java b/spring-test/src/main/java/org/springframework/test/web/servlet/ResultActions.java index 083611f611ae..bc7a401024b9 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/ResultActions.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/ResultActions.java @@ -52,6 +52,38 @@ public interface ResultActions { */ ResultActions andExpect(ResultMatcher matcher) throws Exception; + /** + * Perform a number of expectation. + * + *

Example

+ *
+	 * static imports: MockMvcRequestBuilders.*, MockMvcResultMatchers.*
+	 *
+	 * mockMvc.perform(get("/person/1"))
+	 *   .andExpect(
+	 *     status().isOk(),
+	 *     content().contentType(MediaType.APPLICATION_JSON),
+	 *     jsonPath("$.person.name").value("Jason")
+	 *   );
+	 *
+	 * mockMvc.perform(post("/form"))
+	 *   .andExpect(
+	 *     status().isOk(),
+	 *     redirectedUrl("/person/1"),
+	 *     model().size(1),
+	 *     model().attributeExists("person"),
+	 *     flash().attributeCount(1),
+	 *     flash().attribute("message", "success!")
+	 *   );
+	 * 
+ */ + default ResultActions andExpect(ResultMatcher... matchers) throws Exception { + for (ResultMatcher matcher : matchers) { + this.andExpect(matcher); + } + return this; + } + /** * Perform a general action. *