Assertions
Once a response has been returned from the request, an assertion will be evaluated to verify if value in the response satisfies the requirements.
The assertion is written as a list item (ordered or unordered list) in the following syntax:
- Selector is a value selector, locating a value in the response. See Selectors
- Assertion operator is an assertion operation, which can be unary operator or binary operator. The binary operator requires an expected value as the operand. See Assertion Operators below.
- Expected value is an optional operand, depending on operator.
Assertion Operators
is defined
is defined
is an operator to check if the value is defined in response.
Example
is undefined
is undefined
is an operator to check if the value is not defined in response.
Example
== (Equal)
==
is an operator to check if the value is equal to the expected value.
Value types for this assertion can be a number, string, or regular expression.
Example
!= (Not Equal)
!=
is an operator to check if the value is different from the expected value.
Value types for this assertion can be a number, string, or regular expression.
Example
> (Greater Than)
>
is an operator to check if the value is greater than the expected value.
Value types for this assertion must be a number.
Example
>= (Greater Than or Equal To)
>=
is an operator to check if the value is greater than or equal to the expected value.
Value types for this assertion must be a number.
Example
< (Less Than)
<
is an operator to check if the value is less than the expected value.
Value types for this assertion must be a number.
Example
<= (Less Than or Equal To)
<=
is an operator to check if the value is less than or equal to the expected value.
Value types for this assertion must be a number.
Example
Regular Expression Assertion
Regular expression is used in equality and difference assertion. The pattern is enclosed between slashes like in Javascript.
The value to be asserted with regular expression assertion MUST be string.
Example