Saturday, August 11, 2012

SoapUI assertions using XQurey/Xpath for numeric comparisons

For new test steps, SoapUI adds a single assertion by default. This verifies that the response is actually a SOAP response. Other than this, SoapUI has a rich collection of assertion types to verify the response. One of them is XQurey assertions, work closely with Xpath. Using XQuery assertions not only make verification automatic but also improves the accuracy. Here are a few examples on how to use especially in numeric verifications.

Say your response contains the following XML structure.
     
<items>
  <item>
    <price>1000</price>
    <date>12-12-12</date>
  </item>
  <item>
    <price>110</price>
    <date>10-10-10</date>
  </item>
  <item>
    <price>125</price>
    <date>Sat Aug 11 12:49:05 NZST 2012</date>
  </item>
</items>


  • Counting number of item nodes using XPath assertion is straight forward.
               count(//item)

       which is going to be 3.


  • Compare each price value.



  • Calculate the total of price values.




No comments:

Post a Comment