When using a data source, it is much harder to use an XML Assertor tool statically, because it will check for the same element returned in every example. Instead of searching for a static value, it is helpful to check that the result has the expected value dynamically. In this example, we will ensure the returned title contains the word from the data source.

  1. Right-click the Test 1: getItemByTitle node from the previous exercise and choose Add Output.
  2. In the Add Output wizard, choose Response > SOAP Envelope on the left and XML Assertor on the right, then click Finish.
  3. In the XML Assertor panel that opens, click the Configuration tab and click Add.
  4. In the Select Assertion wizard, expand Value Assertions, choose String Comparison Assertion, then click Next. The String Comparison Assertion dialog displays a tree view of the XML message. From here, you can select a single value to enforce.
  5. Click 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’s Configuration tab, choose contain from the Element must drop-down menu, choose Parameterized from the Expected Value drop-down menu, and choose Keywords from the last drop-down menu.
  7. Save the changes to the XML Assertor Configuration.
  8. Click the Run Tests toolbar button.

Note that the test will fail after a couple runs due to the same XPath we ignored earlier (in Excluding Dynamic Values from Diff Comparisons). If you configure the new Diff tool to ignore that same XPath, the tests will succeed.

  • No labels