Reputation: 43
I use SoapUI NG Pro (ReadyAPI-1.1.0.) and try to use the UI to set all my required assertions.
What I try to do is to check if a list (JSON) contains an element that is defined in a soapUI custom property. To get all elements from the list I use the path: $.devices[*].deviceName
. Now I like to check if the string from the customer property ${#Project#devname.1}
is part of the list.
To write the assertion I found two possibilities, but both of them do not really work.
$.devices[*].deviceName
and the expected result with ${#Project#devname.1}
. I also checked the check box to support wildcards. The result is a positive assertion. SoapUI does what I expect. BUT! If I save the project and reopen it, the check box is not checked any more. I have to go over all my assertions and check the boxes again. This is not a solution because I have about 100 of these assertions.$.devices[*].deviceName
into the input field and used this regular expression: ${#Project#devname.1}
. Sadly this does not work, because SoapUI does not expand the Custom Properties before applying the regular expression. I did not find anything in the documentation explaining how to use custom properties in regular expressions. Could you help here?In any case. What is a good solution for this type of assertions?
Upvotes: 1
Views: 5195
Reputation: 11
You can try to use JsonPath
Match assertion with expression
$.devices[?(@.deviceName=='${#Project#devname.1}')].deviceName.
It will try to find device with
deviceName == devname.1. If exists = true, if not - "Comparison failed for path "...", expecting [%your deviceName%], actual was [[]]"
Upvotes: 1