Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

String Comparison in XML aseertor

Pattu
Pattu Posts: 44

I have to validate a set of currency fields which should not be available in the output message, can i simply select from Value assertion->String comparison assertion and give as below ?
String -> must not equal -> and in the "Fixed" drop down -> simple type as ‘XAG’, ‘XAU’, ‘XBA’, ‘XBB’, ‘XBC’, ‘XBD’, ‘XEU’, ‘XFU’, ‘XPD’, ‘XPT’, ‘XXX’ , so will the field validate all of the currencies or is it wrong input , i have attached screen shot

Answers

  • Pattu
    Pattu Posts: 44

  • Pattu
    Pattu Posts: 44

    @benken_parasoft pls help

  • benken_parasoft
    benken_parasoft Posts: 1,291 ✭✭✭
    edited October 9

    XPath is very powerful in itself. What you can do is create an XPath that matches what you want to make sure is NOT there and then have the "Occurrence Assertion" configured to match 0.

    For example, take this XPath:

    /root/items/item[text()="XAG" or text()="XAU" or text()="XBA"]
    

    It would match 0 nodes on this (assertion passes):

    <root>
     <items>
      <item>A</item>
      <item>B</item>
      <item>C</item>
     </items>
    </root>
    

    It would match 1 node on this (assertion fails):

    <root>
     <items>
      <item>A</item>
      <item>XAG</item>
      <item>C</item>
     </items>
    </root>