DevTest - Ensure JSON Schema Assertion

Document ID : KB000124280
Last Modified Date : 09/01/2019
Show Technical Document Details
Using the Ensure JSON Schema Assertion can give unexpected results.

1. As of this writing, DevTest supports JSON Schema draft 4 only.
2. The websites used in this document are free websites but are not connected to CA or Broadcom in anyway. They are used only for example.

Websites Used:
Schema Generator: 
All supported DevTest  environments.

To use the Ensure JSON Schema Assertion:

  • Create a Draft 4 JSON schema. If no schema exist, one can be created using the schema generator website above.
  • Save the schema to a text file. A good place to save the file is in the Data directory of the DevTest Project.
  • Add a REST step to a test case.
  • Double click on the REST step and open the dialog box.
  • Enter a URL that will return a json response
  • Add the "Ensure JSON Schema" Assertion. In the assertion configuration box:
    • Payload (right side), ensure these settings:
      • Source (drop down list): "From Property"
      • Property Name: lisa.http GET.rsp
    • Schema (left side), ensure these settings:
      • Source (drop down list): "From Content"
      • Click "Browse File System" and select the file containing the JSON schema (created/saved above)
    • Click "Run Assertion". The schema should validate correctly.
      • Click on OK to clear the dialog box. (see next section)
      • See the bottom section "Run Assertion Results" for details.
    •  The "If true/false then ..." section (top line of configuration box).
      • This section defines if the validation should pass or fail and what the next action should be.
      • The setting on this section will effect the message in the dialog box from the previous step. The message displayed in the dialog box, is the results of the "If true/false then ..." section, not if the validation passes.
      • Examples:
        • If true then ..., and the validation passes, "Assertion result = true" is displayed.
        • If false then..., and the validation passes, "Assertion result = false" is displayed.
        • If true then ..., and the validation fails, "Assertion result = false" plus additional information is displayed.
        • If false then..., and the validation fails, "Assertion result = true" plus additional is displayed.
      • Remember the "Run Assertion Results" section will display the actual results of the validation.
  • Close the assertion configuration box when complete
Additional Information:
Not applicable.