JSON Response "JSON - Ensure Result Contains" assertion with multiple values being searched fails
search cancel

JSON Response "JSON - Ensure Result Contains" assertion with multiple values being searched fails


Article ID: 109982


Updated On:


CA Application Test CA Continuous Application Insight (PathFinder)


I have a REST service test that includes an assertion on a request/response of type "JSON - Ensure Result Contains" - and is checking for up to 3 error messages to appear in the JSON returned.

The JSON filter is configured to grab all the text within the tag that contains all the error messages that can be returned.

When executing this test the assertion fails with a message "inventoryItem Controller POST Negative [Ensure Result Contains Error Message: ""] : Verify Response Contains Error Message: "" Invalid JSON result: '{"status":"BAD_REQUEST","errors":["Asset tag length must be 13"]}': Expected a ':' after a key at 28 [character 29 line 1]".

But it only returns this error on the 1st test that executes this assertion. All subsequent tests execute the assertion properly, and even one configured in the exact same way, same data, exactly the same response, will pass after the 1st one executed fails.

I have reviewed the JSON returned and it does not contain unexpected chars and is formatted correctly, even comparing it to a 2nd test configure exactly the same way, same data, same expected result message, and there is no difference in the JSON returned that should produce this error. I have changed this test/assertion in all ways I can imagine, but the only way to ensure the assertion works properly on the 1st data set executed through it is to remove the 2nd and 3rd values to be found in the results.


Release: All supported releases
Component: ITKOTF


Step "inventoryItem Controller POST Negative" did not have the values it needed before doing the assertion on the first iteration.


Needed to do JDBC read "Get Values for Negative Test Expected Results" on "inventoryItem Controller POST Negative" step instead of on the "Verify POST Response Values Negative" step.
Also needed to remove the brackets on the Respose_String2 values.

Once those changes made, then able to run your test with the expected results.