[英]Hamcrest matchers
我在RestAssured響應規范中寫了這樣的內容
builder.expectBody("hotelavailabilities.rateplans.rooms.adults",
anyOf(
hasItemInArray(
anyOf(
hasItemInArray(
anyOf(hasItemInArray(Integer.parseInt(adults))))))));
我想建立一個像上面的斷言,所以我比較json輸出與此斷言
但是我收到如下錯誤
java.lang.AssertionError: 1 expectation failed.
JSON path hotelAvailabilities.ratePlans.rooms.adults doesn't match.
Expected: (an array containing (an array containing (an array containing <2>)))
Actual: [[[2], [2]], [[2]], [[2], [2]], [[2], [2]]]
如何編寫hamcrest,以便覆蓋和聲明輸出?
JSON模式:
有時在房間對象中可能只有一個數組,或者可能有三個,但是2將是常數
終於解決了
hasItem(anyOf(hasItems(anyOf(hasItem(Integer.parseInt(adults))))))));;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.