How to assert custom XML response does not return any unwanted tags in SOAPUI?
I wonder if there is a way to assert that XML response does NOT contain any other tags than those expected? I am using plain http requests (no WSDL, schema validation, not SOAP, not REST) and the application protocol is custom for a particular application (POS systems).
I was thinking (and started) of creating a custom SOAPUI library with script that contains:
- a reference table
- a function that checks if returned tag is on the list (in reference table)
- if the returned tag is not on the list, then assertion fails
So, my question is: is there a better way to validate that? The response XMLs have a lot of fields, some mandatory, some optional and some conditional depending on other (within same request).
Alberto last edited by
If the negative assertions were simple enough I would have suggested using a regex expression. Negative regex expressions are a little trickier than most, and can get ugly fast if you have dependencies between the items you are checking or have a lot of elements to check for/against.
A reference table as you have suggested allows the data to be separated from the code and will allow for easier maintenance.
You can either create a list of expected tags and check that every tag in the response is one of those, or a list of unexpected tags and check that every tag is not one of those. Whichever way you choose should be the one that requires the least maintenance. While the list of acceptable tags may be finite, the list of unacceptable tags may be infinite and you may end up playing whack-a-mole with your dataset by continually adding new tags to disallow.