我正在使用 Jmeter 进行 api 测试,并对响应正文使用 json 路径断言。问题是响应主体根据成功和失败给出了两条响应路径。
对于失败
{
"response": {
"error_message": "Invalid input data.",
"error_code": "Invalid_input",
"error": true
}
}
为了成功
{
"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
,但这仅适用于失败情况
请帮助我在这两种情况下获得正确的路径和断言。谢谢。