To quickly add validations to your SOAP Client and REST Client tools, you can create assertor tools directly from the CTP interface. For SOAP Clients, you can add XML Assertor tools. For REST Clients, you can add either XML or JSON Assertors. Any assertor tools added from CTP will be attached to the response traffic of the selected test.
Additionally, you can edit assertor tools that were added to the response traffic using SOAtest desktop. Any assertor tools that are added to the request traffic using SOAtest desktop will not be visible in CTP.
Diff tools vs. Assertor tools
If you want to check whether all or most parts of a message match a regression control, use a Diff tool. If you want to check a specific element of a message—and/or if you want to validate something other than a match—use an Assertor.
Adding an Assertor Tool
To add a new assertor tool:
- If you haven’t run the associated REST Client or SOAP Client tool, do so now (e.g., by selecting the related .tst tree node and clicking Execute). The tool’s traffic viewer must contain traffic before you can add an assertor.
- In the left pane, select the REST Client or SOAP Client whose response you want to validate.
- Choose Add JSON Assertor or Add XML Assertor from the page-level action menu.
Note that JSON Assertors are available for REST Clients, but not for SOAP Clients.
- (Optional) Modify the name of the newly-created tool.
- Configure the tool as described below.
- Save the new tool configuration.
The new tool will be "chained" as an output to the response traffic of the selected test client tool.
Configuring an Assertor Tool
To configure an assertor tool:
- If the containing test suite includes multiple data sources, you can review and change which data source is used by this tool. See Parameterizing with Data Source and Data Bank Values for details.
- In the tool’s configuration page, click Add Assertion.
- From the dialog that opens, indicate what type of assertion you want to add. Available assertions are described in Assertion Types.
Configure the assertion tool details as appropriate for your selected assertion.
Clicking in the Element field opens the XPath builder, which is described in Specifying XPaths. Select an element in the XPath builder to popular the Element field as well as any other applicable fields (e.g., Expected Value, Expected Type, etc.).
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.
Save expected saves the message received by the associated test client. This message is used by the XPath builder.
- Repeat the above process for each assertion you want to add. A single assertor can check multiple assertions.
The following types of assertions can be added to assertors.
|Value Assertion||Enforce the value of a particular element.|
|Value Occurrence Assertion||Enforce a certain number of occurrences of an element with a given value (e.g., that the document must have n matches on both the XPath selector and the specified value string).|
|Numeric Assertion||Enforce the numeric value of an element.|
|String Comparison Assertion||Enforce the value of the text content of a given element.|
|Regular Expression Assertion||Enforce that an element matches a regular expression|
|Occurrence Assertion||Enforce the number of occurrences of an element.|
|Has Content Assertion||Enforce that an element has text content (i.e., length of text > 0).|
Enforce the type of an element.
This is available for JSON Assertors only.
|Numeric Range Assertion||Enforce that the numeric value of an element is within the inclusive bounds of a numeric range.|
|Date Range Assertion||Enforce a date range on a value of a particular element.|
|Date Time Range Assertion||Enforce a date time range on a value of a particular element.|