Verifying Results

Use ReadyAPI assertions to validate response and request contents: response codes, header values, specific fields in JSON and XML response bodies, and so on.

Validate the response content and add more specific assertions to check if the service gets and returns data in the expected format and whether it functions properly.

To learn more about available assertions and their parameters, see Assertion Reference.

Smart assertion

The easiest way of validating responses is with the Smart Assertion. It checks both the message content and the metadata such as headers, status codes, and parameters in accordance with the predefined set of rules. You can create a Smart Assertion from the Assertion panel. For REST, GraphQL, and SOAP requests, you can create it from the response editor as well:

For details about configuring the assertion, see the Smart Assertion reference.

Create assertions

Group assertions

You can group assertions together into logical assertion groups.

An assertion group behaves like a regular assertion: it can either pass or fail. Its status depends on statuses of assertions included in it and the logic applied: it can either pass if at least one of its assertions passes, or pass only if all its assertions pass.

An assertion group can include other assertion groups, but only one level deep. In other words, Group A can include Group B, but Group B cannot include Group C in its turn.

Tip

Assertion groups are especially useful when testing asynchronous APIs like Kafka where one test step receives multiple messages.

Create assertion group

To create an assertion group:

  1. Open a test step in the editor and click assertion-group.png in the Assertions panel.

    Note

    To create an assertion group, the test step must have at least two assertions.

  2. Select the logic that will decide if the assertion group passes:

    • AND – The assertion group passes if each assertion included in it passes.

    • OR – The assertion group passes if at least one assertion included in it passes.

  3. Select assertions that will be included in the group and click Add Group:

    Functional tests: Add assertion group

Remove assertion group

To remove an assertion group, select it in the Assertions panel and click assertion-ungroup.png:

Remove assertion group

Clone assertions

You can clone assertions and assertion groups you used in a request or response and apply them to another test step in the same or another test case or project. To do this, click clone-new.png on the toolbar of the Assertions panel and configure the following options as needed and apply the changes:

ReadyAPI: The Clone Assertions dialog

Option

Description

Assertions

A list of available assertions to clone.

Target Project

A project to clone the assertion to.

Target Test Suite

A test suite to clone the assertion to.

Target Test Case

A test case to clone the assertion to.

Target Test Steps

A list of available test steps to clone the assertion to.

Overwrite

Assertions of some types can be added several times to a test step, while assertions of some other types can be added only once. The Overwrite option affects cloning of such “one-instance” assertions:

  • If the option is on, clones will replace such assertions in the target test steps.

  • If the option is off, clones will not replace the existing assertions.

The option does not affect multiple-instance assertions: ReadyAPI always adds copies of these assertions to the assertion list.

Clear Existing

Removes any existing assertions with the same name.

Open List

Displays the list of updated test requests.

Assertions panel

The Assertions panel lists the assertions you added to a test step or operation. Here, you can add and modify the assertions.

To access the Assertions panel:

See Also

Publication date: