我正在使用 Jmeter 进行 api 测试,并对响应正文使用 json 路径断言。问题是响应正文给出了基于成功和失败的两条响应路径。
for failure
{
"response": {
"error_message": "Invalid input data.",
"error_code": "Invalid_input",
"error": true
}
}
for success
{
"response": [
{
"attachment_name": "num1.png",
"attachment_id": 2547,
"error": false
},
{
"attachment_name": "num2.png",
"attachment_id": 2548,
"error": false
},
{
"attachment_name": "num3.png",
"attachment_id": 2549,
"error": false
}
]
}
这里添加对“错误”路径和值的断言,但路径会根据结果发生变化。
添加了 $.response.error
但这仅适用于失败情况
请帮助我在这两种条件下获得正确的路径和断言。谢谢。
最佳答案
关于performance - JMeter json路径断言响应中的json或数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59667395/