[英]Asserting Rest Assured response with Json Unit
我目前正在使用放心和 Json-unit 針對請求的放心響應斷言本地 json 文件。
我目前有一個帶有我的基本 uri 的類前方法。
我不知道如何做出這種斷言。 我正在為 json-unit 文檔苦苦掙扎。 我需要先輸入一個文件嗎?
@Test
public void ApiaryTest1() throws Exception {
when()
.get("/test")
.then()
.statusCode(200);
// compares two JSON documents
assertJsonEquals("expected/test.json", "http://apiary/test");
}
你需要:
示例:
Response response = when().get("<url>");
response
.then()
.statusCode(200);
// compares two JSON documents
assertJsonEquals(resource("resource-inside-resources-folder.json"), response.asString());
對於放心的 Kotlin DSL:
When {
get("http://nowjidev1vm01.ath.bskyb.com/calskyplussearch/health")
} Then {
statusCode(200)
} Extract {
assertJsonEquals(expectedBody, response().asString())
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.