Working With Assertions in Functional Tests

Applies to ReadyAPI 3.8, last modified on May 17, 2021

In functional tests, you can apply assertions to various types of test steps. Depending on the test step type, there are different assertions available.

Prepare a test step

  1. Double-click the test step in the Navigator to open its editor.

  2. Run the request you are planning to assert at least once to get the response from the endpoint. To do that, click .

    Note: If you want to add the assertion for the SOAP VirtResponse test step, run the request you have associated with this virtual response.

Now, you can use the response data during the assertion creation.

Create assertions from the response

Create a smart assertion

ReadyAPI can analyze previously received REST, GraphQL, and SOAP responses and generate an assertion based on the recognized patterns. To validate a response:

Adding validation of REST, GraphQL, and SOAP responses

Click the image to enlarge it.

  1. Send a request, using the REST Request, GraphQL Query, GraphQL Mutation, or SOAP Request test step.

    Tip: It is better to send a request several times. This produces more data ReadyAPI can analyze.
  2. Click Smart Assertion in the Response editor.

    ReadyAPI analyzes the history of received responses and adds the preconfigured Message Content assertion.

    Note: Smart Assertion analyzes only the data collected during the current session of ReadyAPI. If you restart ReadyAPI, you'll have to run a request again before you can add Smart Assertion to it.
  3. See the settings in the subsequent Message Content Assertion dialog and modify them, if needed.

    Click Save.

Smart Assertion does not work if the Test History disabled option is enabled.
Create an assertion for a specific element

You can quickly add assertions for specific elements in the response. To do that:

  1. Right-click the element you want to check in the Outline panel of the response editor.

  2. Select the desired assertion from the Add Assertion menu item.

    There are the following options:

    • for Content – checks whether the selected element contains the specified value.

    • for Count – checks whether the selected element appears the specified number of times.

    • for Existence – checks whether the selected element exists in the response.

    • for Content matching RegEx – checks whether the selected element matches the specified regular expression.

    • for Existence with Script – checks whether the selected element exists in the response by using a Groovy script.

Open the Assertions panel

To open the Assertions panel, click Assertions at the bottom of the test step editor.

ReadyAPI: The Assertions panel in ReadyAPI

Click the image to enlarge it.

Group assertions

For functional tests, you can group assertions into assertion groups. Such groups behave like regular assertions and pass or fail based on the status of assertions included in them. To learn more about working with assertion groups, see Group Assertions.

ReadyAPI: Assertion groups

Related Topics of Interest

Assertion Coverage

Describes where you can find assertion coverage data and how to use it.

See Also

Functional Testing
Verifying Results
Assertion Reference
Transferring Property Values

Highlight search results