问题
I'm using soapUI 5 (non pro) and all i need is to validate(assert) a number is greater than zero in the expected result section. So this means
1) in XPath expression(Xpath match) I am declaring the below (I need to remove all text and only have numbers then check that number is greater than zero)
replace(//OUTBOUND_MESSAGE.MESSAGE_CONTENT, '[^0-9]','')
2) All i want to do in expected result is =!0 or number>0 so i attempted
${=!0}
but doing that brings back a boolean T/F. I'm really lost :(
回答1:
The expression ${=!0}
is not working as you expect. In SOAPUI this kind of expressions ${=expression}
are executed as groovy script so really SOAPUI is executing !0
which is result is true and this is the expected result. This is why SOAPUI throws replace..., expecting [true]
.
I think that it's better to change you XPath expression
to evaluate directly if your expression is >0
:
number(replace(//OUTBOUND_MESSAGE.MESSAGE_CONTENT, '[^0-9]',''))>0
And as expected result simply set true
.

来源:https://stackoverflow.com/questions/28872959/comparing-operands-xpath-assertion-expression-with-expected-result-in-soapui