Submit and vote on feature ideas.

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.

DB Assertion Regardless of order

SOAtoad Posts: 14

I have a test where I query a DB and returned with a list of values. I want to be able to make an assertion to check if certain values exist regardless of order or position in the result. Is this possible?
So far, my team mates who are working on this as well have been unsuccessful


  • jakubiak
    jakubiak Posts: 775 admin

    Probably the easiest way is to attach an XML Sort tool to the DB Tool "Results as XML" output, and then to the XML Sort tool add an XML Assertor where it will then be easier to add assertions to the sorted elements.

  • benken_parasoft
    benken_parasoft Posts: 1,087 ✭✭✭
    edited February 2019

    If sorting helps, you can also use an "ORDER BY" clause in your SQL statement.

    Alternatively, without sorting anything, you can configure an XML Assertor with an Occurrence Assertion having an XPath that only matches on the one particular element regardless of order. For example, let's say your XML is this:


    Let's say you want to check if this contains an item element with value 3. In that case you would create an Occurrence Assertion with expected value == 1 with XPath /root/item[text()=3].