Page tree

Skip to end of metadata
Go to start of metadata

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:

  1. 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.
  2. In the left pane, select the REST Client or SOAP Client whose response you want to validate.
  3. 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. 
  4. (Optional) Modify the name of the newly-created tool.
  5. Configure the tool as described below.
  6. 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:

  1. 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.
  2. In the tool’s configuration page, click Add Assertion.
     
  3. From the dialog that opens, indicate what type of assertion you want to add. Available assertions are described in Assertion Types.
     
  4. 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.

  5. Repeat the above process for each assertion you want to add. A single assertor can check multiple assertions.

Assertion Types

The following types of assertions can be added to assertors.

Value Assertions

TypeDescription
Value AssertionEnforce the value of a particular element.
Value Occurrence AssertionEnforce 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 AssertionEnforce the value of the text content of a given element.
Regular Expression AssertionEnforce that an element matches a regular expression

 

Structure Assertions

TypeDescription
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).
Type Assertion

 Enforce the type of an element.

This is available for JSON Assertors only.

 

Range Assertions

TypeDescription
Numeric Range AssertionEnforce that the numeric value of an element is within the inclusive bounds of a numeric range.
Date Range AssertionEnforce a date range on a value of a particular element.
Date Time Range AssertionEnforce a date time range on a value of a particular element.



  • No labels