我有一些使用 RestAssured 的 java 测试。对于许多测试,given() 和when() 参数不同,但then() 部分是相同的并且由多个assertThat() 语句组成。如何将 then() 块移动到可以反复使用的新方法?
@Test
public void test_inAppMsgEmptyResponse() {
given().
contentType("application/json").
when().
get("inapp/messages.json").
then().assertThat().
statusCode(HttpStatus.SC_OK).
assertThat().
body("pollInterval", equalTo(defaultPollInterval)).
assertThat().
body("notifications", hasSize(0));
}
Run Code Online (Sandbox Code Playgroud)