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` assertion_operator `expected_value`
  • 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

* `Body.message.id` is defined

is undefined

is undefined is an operator to check if the value is not defined in response.

Example

* `Body.message.error` is undefined

== (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

* `StatusCode` == `200`
* `StatusText` == `"OK"`
* `Headers.Content-Type` == `"application/json"`

!= (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

* `StatusCode` != `404`
* `StatusText` != `"NOT FOUND"`
* `Headers.Content-Type` != `"text/plain"`

> (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

* `Body.id` > `0`

>= (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

* `Body.id` >= `0`

< (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

* `Body.id` < `30`

<= (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

* `Body.id` <= `30`

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

* `StatusText` == `/^NOT.*/`