This topic covers the JSON Assertor tool, which lets you place assertions on different elements in a JSON message. This tool requires a validate license.

Sections include:

The JSON Assertor tool was re-implemented in version 9.7. The previous implementations are deprecated: any existing tools will continue to work, but all new JSON Assertors you add will use the new implementation.

This topic focuses on the current JSON Assertor implementation.For details on the deprecated JSON Assertor, see JSON Assertor Deprecated.

Understanding JSON Assertor

JSON Assertor is used to enforce the correctness of data in a JSON message.  It enables you to introspect into individual elements in JSON messages and check whether they meet expectations. 

JSON Assertor can be chained against any tool that communicates a JSON message, It is most commonly connected with the Messaging Client and REST Client tools.

This tool is often added from the Create/Update Regression Control dialog for JSON messages (by choosing the Create Value Assertion option). For details on adding JSON Assertors in this manner, see Validating the Value of an Individual Response Element.

It can also be added via the Add Output wizard, which is described in Adding Test Outputs.

Configuring JSON Assertor

JSON Assertor consists of three main tabs:

To configure JSON Assertor:

  1. Click the Add button in the JSON Assertor’s Configuration tab.

    The Select Assertion wizard displays.

  2. Select an assertion type. The following is a brief summary of the available types of assertions.
  3. Click the Next button. A tree view displays.
  4. From the tree view, select the element that you want this assertion to check, then click the Finish button.

    Note that you can edit the structure of this tree in the tool’s Expected JSON tab (described above).

You may add additional assertions to apply to the message by clicking the Add button in the Configuration tab.

If you later want to specify additional options (e.g., if you want to change the name of the column used to store the value, you want the value saved to a writable data source, or you want the value stored to an existing variable) —or if you want to modify the referenced element—then click the Change Element button which is at the bottom right of the Configuration tab. This opens a dialog that lets you graphically or manually edit the given element. 

For details on how to use this dialog to configure additional options, see JSON Selector Reference.

Tool Options

The Trim content option will remove any white space from the start and end of the extracted string before comparing it to the expected text. For example, if "  bar " was extracted (ignore quotes in all examples; they are used to show white spaces), it would become "bar"; this would match "bar" (and fail to match "  bar ") if the Trim content option was not enabled.

Video Tutoral 

In this video, you'll learn how to add targeted assertions for values in JSON responses.