Overview
Assertion validates whether the response from the API matches an expected one. The response can be compared using various operators to verify if they satisfy expected outcomes.
Assertions can be applied using:
Source: Specifies which aspects of the response or what type of response are being compared or evaluated. You can select the source as Header, Status Code, XML Body, or JSON Body.

Note: Ideally, when performing assertions with comparisons, the data type of the actual value derived from the given property should match the data type of the expected value. If there is a mismatch, the assertion will fail.
In the example below, the required operators are applied to values, comparing them to determine whether the response aligns with the expected outcome.
The following table lists the respective operators for each data type:
Data Types | Applicable Operators |
Boolean | |
Number | Equals - Verify if a numerical value returned by the API matches an expected value.
Not Equals - Verifies that a numerical value returned by the API does not match a specific value.
Lesser Than - Verifies if a numerical value returned by the API is less than a specified threshold.
Lesser Than Or Equal To - Checks if a numerical value returned by the API is less than or equal to a specified threshold.
Greater Than - Verifies if a numerical value returned by the API exceeds a specified threshold.
Greater Than Or Equal to - Checks if a numerical value returned by the API is greater than or equal to a specified threshold.
|
String | Equals - Verifies if a string returned by the API matches an expected string exactly.
Not Equals - Checks if a string returned by the API does not match a specified string.
Contains - Verifies if the string returned by the API contains the expected string.
Not Contains - Checks if the string returned by the API does not contain the expected string.
Is Empty - Validates if a string returned by the API is empty (has zero characters).
Is Not Empty - Checks if the string returned by the API is not empty (contains one or more characters).
Starts With - Verifies if the string returned by the API starts with the specified prefix.
Ends With - Validates if a string returned by the API ends with the specified suffix.
Length - Validates the length of a string returned by the API against the expected length.
Note: Operators used to perform comparison for the string data type are case-sensitive. |
JSON | Array Count - Verifies the count of elements in the expected JSON array returned by the API.
Has Key - Verifies whether a specific key from the API response exists in the expected JSON response.
Note: Comparison using the "Has Key" operator is case-sensitive.
Is Null - Verifies if a specific value from the API response is null in the expected JSON response.
Is Not Null - Validates that a specific value from the API response is not null in the JSON response.
Schema Validation - Ensures that the data from the API response conforms to the structure and data types defined in the expected JSON.
Object Equals - Checks that the received JSON and the expected JSON are identical in structure, values, data types, and keys.
Note: Comparison using the "Object Equals" operator is case-sensitive.
|
Regex | Matches - This is used for Regex validation. A Regex pattern is given in the value field, and the value associated to the specified key returned from the JSON response is validated with this pattern. |
The following is a sample JSON key-value response