Response Assertion

Response Assertion Post Processors lets you check at runtime the HTTP responses satisfy conditions, e.g.:

  • The response body must contain some text,
  • A response header must have a certain value,
  • The response code must be 200.

Assertions can be graphed in bench reports.

Response Assertion

The first line displays the response assertion name. This field is optional. The second line contains tab headers to access:

  • Simple Configuration, to easily generate an assertion,
  • Advanced Configuration, for more specific needs

The check button, on the right of the action, lets you validate the assertion against the selected HTTP response:

  • Green: the assertion is valid for the selected response,
  • Orange: the assertion is invalid for the selected response.

Note

The response selector, on the right, lets you choose which HTTP response is used for configuring and checking the Response Assertion. So if neither recorded responses nor Validate VU responses are available, you have to configure the Response Assertion blindly.

Simple configuration

Body assertion

The following procedure explains how to simply configure an assertion on a HTTP response body:

  1. Select the Configuration tab,
  2. Select Body on the right toggle buttons,
  3. Browse the response body, and select the text that must be present for each HTTP repsonse.

Header assertion

The following procedure explains how to simply configure an assertion on HTTP response headers:

  1. Select the Configuration tab,
  2. Select Headers on the right toggle buttons,
  3. Select the header in the table, its value must be the same in every HTTP response.

Status code assertion

The following procedure explains how to simply configure an assertion on a HTTP response status:

  1. Select the Configuration tab,
  2. Select Status code on the right toggle buttons,
  3. The recorded status code is displayed on tp of the panel,
  4. Select the status code in the selector, its value must be the same for every HTTP response.

Advanced configuration

You may start by using the simple mode, and then switch to advanced to customise the generated configuration.

The Advanced tab may fulfil more complex requirements.

The following procedure explains how to configure an assertion on a HTTP response:

  1. Select the Advanced tab,
  2. Select the response part to assert: Headers, Body or Status code on the right toggle buttons,
  3. Select the Apply to value, the request with or without its sub-requests,
  4. Select the Pattern matching rule,
  5. Select whether to negate the patterns,
  6. Type in one or more patterns in the bottom table.

Warning

The Apply to is only relevant if the parent HTTP Request action has the Download resources? option enabled. Otherwise there will not be any sub-request.

Note

The patterns depend on the Pattern matching rule:

  • Contains: the patterns are only simple strings that must be present anywhere in the response part,
  • Matches: the patterns are regular expressions that must match the response part,
  • Equals: the patterns strings that must be the same as the whole response part (only relevant with the Status Code).