DB Assertion Regardless of order

SOAtoadSOAtoad 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


  • jakubiakjakubiak Posts: 673 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_parasoftbenken_parasoft Posts: 895 ✭✭✭
    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].

Sign In or Register to comment.