[英]Rest Assured - How to Validate Json response value based on value of previous Json node
In Rest Assured , I send a get request and below Json response is received.
// Json回應
{
"data": [
{
"Name": "REST",
"Description": "Representational state transfer"
},
{
"Name": "SOAP",
"Description": "Simple Object Access Protocol"
}
}
}
我想驗證名稱是否為REST,然后描述為代表性狀態傳輸,如果名稱為SOAP,則描述為簡單對象訪問協議。 響應中有20多個類似的記錄,我如何通過使用通用參數放心地做到這一點。
Also please advise how to parameter and do the assertion otherwise it will lead to more than 20 line of assertions alone.
完成如下
given()
.when().get(url)
.then()
.root("data")
.root("find { it.Name == 'REST' }")
.body("Description", equalTo("Representational state transfer");
希望你能明白。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.