I am doing api testing with Jmeter and using json path assertion to the response body. Problem is response body is giving two response path based on success and failure.
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
}
]
}
Here am adding assertion on "error" path and value but the path changes on the result.
Added $.response.error but this works only for failure case
Please help me to get correct path and assert in both the conditions. Thanks.


You can use deep scan operator
.., the relevant JSON Assertion configuration would be something like:whenever you get
errorJSON attribute with the value oftruethe Assertion will fail the relevant Sampler(s) in its scope