The Assertion test step expands the idea of assertion handling and management. It provides the flexibility of creating simple and complex assertions that can assert any property from the project level to individual test steps in a test case, as well as request, response, JMS, JDBC or Security-related activities. You can also group assertions to use the Boolean logic.
You need to disable the Discard Successful Results in the TestCase Options dialog to use the Assertion test step, because it requires access to that information.
The Max Results option in the TestCase 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.
You can modify settings of a test step in its editor:
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.
|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.
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.|
Text describing the test step.
The test step’s name.
The test step’s name.
Text describing the test step.
The test step toolbar contains commands that modify the selected test step or the appearance of the test step editor.
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.
When the test step is run as part of a test case, you can see the log in the Transaction Log panel.
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.
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.
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.
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:
Click to add an assertion.
In the ensuing Add Assertion dialog, select the asserted item in the Source drop-down list:
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:
The dialog will show available assertions:
Choose an available assertion from the dialog and click Add.
The assertion is added to the Assertion test step.
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.
You can group two or more assertions to provide combined validation:
Select two or more assertions by holding CTRL and clicking all assertions you are planning to group:
Click 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:
|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:
|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.
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.
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.
Finally, grouping provides flexibility of nested groups of assertions: