【发布时间】:2021-02-24 08:02:20
【问题描述】:
我在黄瓜步骤定义中有这个
secondIT.jsonPathEvaluator = secondIT.response.jsonPath();
然后在另一个步骤 def 中,我断言,我有
public void employee_response_equals(DataTable responseFields){
List<Map<String,String>> fields = responseFields.asMaps(String.class,String.class);
Iterator<Map<String, String>> it = fields.iterator();
while (it.hasNext()) {
Map<String, String> map = it.next();
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
assertEquals(secondIT.jsonPathEvaluator.get(entry.getKey()), entry.getValue());
assertAll(
// how to use this instead
);
}
}
}
如何使用 junit5 assertAll 断言每个键获取的值(来自 jsonPathEvaluator)和来自映射的值
我尝试使用assertEquals,但我不确定这是否正确,因为它只打印一些信息,即key = data.id,当我评论该行时,它会打印所有内容
key = data.id
value = 2
key = data.employee_name
value = Garrett Winters
另外,我遇到了this,但我不确定如何为我的场景制作可执行文件
样本数据表:
And response includes the following employee info
|key |value|
| data.id | 3 |
| data.employee_name | Garrett Winters |
和示例响应:
{
"status": "success",
"data": {
"id": 2,
"employee_name": "Garrett Winters",
"employee_salary": 170750,
"employee_age": 63,
"profile_image": ""
},
"message": "Successfully! Record has been fetched."
}
【问题讨论】:
标签: java junit junit5 cucumber-jvm