You can use the XML Assertor tool to enforce the correctness of data in an XML message. It is most commonly connected to a SOAP Client or Messaging Client in order to verify the data returned by a service. The XML Assertor provides support for complex message validation needs without the need for scripting, and allows you to easily create and maintain validation assertions on your XML messages.

To use the XML Assertor, complete the following:

  1. Right-click the Test 1: getItemByTitle node from the previous exercise and select Add Output from the shortcut menu.



  2. In the Add Output wizard, select Response> SOAP Envelope on the left, select XML Assertor on the right, and click Finish.



  3. In the XML Assertor panel that opens, open the Configuration tab and click Add.



  4. In the Select Assertion wizard, expand Value Assertions, select String Comparison Assertion, then click Next.



    The String Comparison Assertion dialog displays a tree view of the XML message from which you can select a single value to enforce.
  5. Select the name element from the String Comparison Assertion dialog and click Finish.



    The Configuration tab of the XML Assertor is now populated with a String Comparison Assertion.
  6. In the XML Assertor panel, choose the Configuration tab
  7. In the String Comparison Assertion Configuration section, choose contain from the Element must drop-down menu and enter Linux in the Expected Value field.



  8. Save the changes to the XML Assertor Configuration.
  9. Click the Test toolbar button. The test succeeds.

You may add additional assertions to apply to the message (such as a Numeric assertion to enforce on the price element) by clicking the Add button in the XML Assertor’s Configuration tab.

  • No labels