Assertion Test Step

Applies to ReadyAPI 3.57, last modified on December 20, 2024

About Assertion test step

Usually, when you want to verify a service response, you use assertions configured within request test steps. The Assertion test step runs as a separate test step, so you can perform verification in any place of your test.

The Assertion test step can assert properties of test steps within a test case as well as properties of a test case, test suite, or project. You can also group assertions to create more complex behavior by using Boolean logic.

The test step can be helpful, for example, if you want:

  • to assert property values;

  • to postpone test case failing in the case of an unexpected response;

  • to assert test steps that do not have a built-in assertion mechanism (for example Run Test Case, Data Source);

  • to implement complex behavior by verifying the results of several requests in a single test step.

Requirements

  • To use this test step, you need a ReadyAPI Test license. If you do not have it, you can request it on our web site or start a trial.

  • You need to disable the Discard Successful Results in the Test Case Options dialog to use the Assertion test step, because it requires access to that information.

  • The Max Results option in the Test Case Options dialog must be set to 0 or the value must be high enough so that the results you want to assert are not discarded before the Assertion test step is run.

Editing Assertion test step

You can modify settings of a test step in its editor:

Assertions test step editor

Click the image to enlarge it.

The test step editor contains a list of assertions to verify.

Right-click an assertion or a group to open its context menu with the following commands:

Add Assertion / Add Assertion to Group Opens the Add Assertion wizard that you use to select and configure a new assertion. Click in a group to create the assertion within the selected group. Otherwise, the assertion will be created at the top level.
Move Assertion to Group Opens a dialog where you can choose a group to move the selected assertions to. Applicable to both grouped and non-grouped assertions.
Ungroup Assertions Removes an assertion from the group. Assertions that are in a subgroup will be moved to a parent group.
Disable/Enable Assertions Disables or enables the selected assertions. Disables assertions which are not considered when a test case is executed during a test run.
Rename Changes the group or assertion name in the table.
Remove Assertions Deletes the assertion from the list.
Clone Assertions Opens the Clone Assertion dialog to copy an assertion to a different test step in the same or a different project.
The cloned assertion will inherit the assertion’s configuration.
Change Source and Property Opens the Edit Assertion dialog where you can change the asserted step and property.
Configure Assertion Opens the assertion configuration dialog.
Tip: Some assertions require no configuration and have no configuration dialog.

Property list

Besides the test step editor, you can adjust the test step’s behavior by using its properties in the Properties tab in the Navigator.

The Assertion test step does not support custom properties.
Name Description
Name

The test step’s name.

Description

Text describing the test step.

Test step toolbar

The test step toolbar contains commands that modify the selected test step or the appearance of the test step editor.

Assertions test step toolbar

Click the image to enlarge it.

Here is a description of some commands:

  • Group – Unites the selected assertions to a group.

  • Ungroup – Separates assertions of the selected group to individual assertions.

Logging

When the test step is run as part of a test case, you can see the log in the Transaction Log panel.

Remarks

Moving or removing test step

Since the Assertion test step needs to be performed after the test steps it refers to, when you move or delete an assertion source and property, some side effects may occur.

Removing

If you assert a test step and it is deleted, all assertions attached to it will also be deleted. The same result occurs when a property asserted inside the Assertion test step is deleted.

Moving

If you move a source test step after the assertion test step or you move the assertion test step before the source test step, ReadyAPI shows a warning message that you may lose the assertions related to this source test step. Click OK to move the step or Cancel to stop.

Working with

Below, you can find information on common tasks that you can perform with the Assertion test step.

Adding assertions to the assertion test step is similar to adding assertions to other test steps, but you have a few more options. For more information about assertions and assertion types, see Assertions.

When the test step has been created, you can start adding assertions:

Testing web services: Blank assertion test step

Click the image to enlarge it.

  • Click to add an assertion.

  • In the ensuing Add Assertion dialog, select the asserted item in the Source drop-down list:

    Testing web services: Select Source

    Click the image to enlarge it.

    After selecting the source, the Properties drop-down list displays the properties of the selected item. The drop-down list is disabled if there are no properties to assert. If the selected source is a test step, the Response property will be selected by default.

    If the selected source is the parent item of the test step (i.e., project, test suite, or test case) and if it has qualified properties to assert on, then a property can be optionally selected.

  • Select the property to assert:

    Testing web services: Select Property

    Click the image to enlarge it.

  • The dialog will show available assertions:

    Choose an available assertion from the dialog and click Add.

    Testing web services: Available assertions

    Click the image to enlarge it.

  • The assertion is added to the Assertion test step.

    Testing web services: Added assertion

    Click the image to enlarge it.

To change the source or property of the created assertion:

  • Right-click the assertion you want to change and select Change Source and Property.

  • In the Select Source And Property dialog, select the source and property.

    If you want to update assertion settings after these changes, select Open configuration dialog.

    Testing web services: Changing assertion source and property

    Click the image to enlarge it.

  • Click OK.

You can group two or more assertions to provide combined validation:

Grouping
  • Select two or more assertions by holding CTRL and clicking all assertions you are planning to group:

    Testing web services: Select several assertions

    Click the image to enlarge it.

  • Click Group on the test step toolbar.

    – or –

    Right-click one of the selected assertions and select Group Assertions.

  • In the ensuing Group Assertions dialog, configure a new group:

    Testing web services: Group Assertions dialog

    Click the image to enlarge it.

    Option Description
    Group Name Identifier for the group.
    Operation Logical operation to be applied to the group members.

    You can use either the AND or OR boolean operation:

    • AND – All assertions must be PASS to mark a group as PASS.

    • OR – At least one assertion within the group must be PASS to mark a group as PASS.

    Expression (Not editable) The evaluated expression constructed from the assertions in the group.
  • The assertion group is added to the assertion table.

A test case containing an Assertion test step can be run just as any other test case.

In the Navigator, double-click the test case with the Assertion test step and click the play button in the editor. The test case is executed and the assertions in the Assertion test step are evaluated.

Testing web services: Run test case for asserting

Click the image to enlarge it.

The picture below demonstrates an example of how the assertions, grouped and non-grouped, are evaluated. Failed assertions in a group with the OR logic are marked as FAIL, but the group itself is PASS.

Testing web services: Assertions in the OR group

Click the image to enlarge it.

Modify the group to use the AND logic. Rerun the test case. The picture below shows an example of the failed assertion causing the entire group to have a FAIL status.

Testing web services: Group assertion

Click the image to enlarge it.

Finally, grouping provides flexibility of nested groups of assertions:

  • Expand a group of assertions.
  • Hold the CTRL key and click the desired assertions to subgroup.
  • Perform a right-click and select Group assertions to create the subgroup.

See Also

Verifying Results
Test Steps

Highlight search results