How to check for NOT this number in SoapUI Assertion

邮差的信 提交于 2020-01-25 11:50:07

问题


I am writing some Soap UI tests and am trying to figure out if there is a way with regular expressions to check for a string that does not contain a specific number. In this one case I want to make sure that when I get a response that my recordCount field DOES NOT contain 0. I thought this might be easier but while I can see a way to check for a set of numbers the regular expression for not this doesn't seem to work. Probably only detects characters and not numbers.

My XML contains this:

<recordCount>0</recordCount>

What I want is something like

recordCount>[^0]

so I can make sure recordCount shows up in the response, but also check that at least the first number it finds is not a 0. Is there any way to do this?

Edit: Using SiKing's answer I just used the NotContains to look for recordCount>0 ; this covers the couple of cases where I don't look for specific data only how many records are returned and in those cases it just needs to be more than 0


回答1:


Why does it have to be regular expression?

You can use either of the following XPath assertions, for all of which the expected result is false:

//*:recordCount = 0
exists(//*:recordCount[text()='0'])



回答2:


Using regular expressions you could do something like that:

(?s).*<recordCount>[^0]</recordCount>(?s).*

When using regular expressions in an assertion in SoapUI, you have to take whitespace and line breaks into account. In the example code (?s).* works as a wildcard that includes all whitespace and line breaks.



来源:https://stackoverflow.com/questions/25432549/how-to-check-for-not-this-number-in-soapui-assertion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!