JSON assertion validation for status code 200.
My script reads test data from excel which also has a status code( expected result) column in it. Scripts fetches data from excel and compares it with status code to validate. Since output of my API is generated in JSON format, I am using JSON asserter to validate status code. The problem that I am facing is for a scenario which successfully execute with status code 200. There is no status code being captured in “Tree” in JSON Asserot Expected JSON tab. it works fine for other status code(400,404,500). Any suggestion how to handle this situation?
Comments
-
First create an Occurrence Assertion that validates that the number of instances of the status element is equal to 1. Then create a Value/Numeric Assertion that validates the value of the status code. Lastly, create a Conditional Assertion that uses the Occurrence Assertion as the "if" and the Value/Numeric Assertion as the "then". This will have the effect that the Value/Numeric Assertion will only get run if the status element is present in the response.
0 -
Thank you for your quick response. Actually i want to validate status code in header section against the status code that is present in excel. which assertion can be used?
0 -
If you want to validate the status code in the header, you can configure the "Valid HTTP Response Codes" field in the Success Criteria tab of your REST or Messaging Client. That field can be configured to pull from a data source.
0 -
Thank you.
0