SK-Sly
11 years agoNew Contributor
How to assert on a JSON element using wild cards and a custom property?
I’m evaluating SoapUI NG Pro (ReadyAPI-1.1.0.) for our project and think I found a bug in assertions for JSON responses.
My project was initially created by SoapUI and then continued with SoapUI Pro.
What I’m trying to do is to assert on a returned JSON element using a regular expression. To do this I found two possibilities, but both of them do not really work!
- Use JsonPath Match
The menu servers an input field for the path and one for the expected result and a check box named “Allow Wild…”. I filled the path with “$.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. Small remark: For any reasons the existence of this check box is not documented here: http://readyapi.smartbear.com/structure/assertions/property/json/match - Use JsonPath RegEx Match
A nice way not use the broken “Allow Wild…” checkboxes should be to use a regular expression instead. Therefore I use the “JsonPath RegEx Match” and put the right path “$.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 result I am not able to write an assertion that matches a single JSON element using a custom property and a wild card.