JJB*_*JJB 4 java rest rest-assured web-api-testing rest-assured-jsonpath
如何使用放心的 .body() 方法在“描述”数组中断言我的属性。
例子:
.body ("[0] .userType", equalTo (1)); // error
Run Code Online (Sandbox Code Playgroud)
这是我当前想要断言的 JSON 数据:
{
"validSession": true,
"value": "xxx",
"description": [
{
"userType": 1,
"userTypeDescription": "xxx",
"uname": "xx",
"distributorId": 1
}
]}
Run Code Online (Sandbox Code Playgroud)
我编辑了一下:
.body("validSession",is(true))
.body("description[0].userType", equalTo(1))
.body("description[0].userTypeDescription", containsString("xxx"))
.body("description[0].uname", containsString("xx"))
.body("description[0].distributorId", equalTo(1));
Run Code Online (Sandbox Code Playgroud)
我测试过并且有效。但我不明白为什么它只能通过将数组的所有元素的索引为零来工作。
你可以解释吗?
归档时间: |
|
查看次数: |
22220 次 |
最近记录: |