将操作数 xpath 断言表达式与soapUI 中的预期结果进行比较 [英] comparing operands xpath assertion expression with expected result in soapUI
问题描述
我使用的是soapUI 5(非专业版),我只需要验证(断言)预期结果部分中的数字是否大于零.所以这意味着
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) 在 XPath 表达式(Xpath 匹配)中我声明如下(我需要删除所有文本并且只有数字然后检查数字是否大于零)
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) 我想要在预期结果中做的是 =!0 或 number>0 所以我尝试了
2) All i want to do in expected result is =!0 or number>0 so i attempted
${=!0}
但这样做会带回布尔 T/F.我真的迷路了:(
${=!0}
but doing that brings back a boolean T/F. I'm really lost :(
推荐答案
表达式 ${=!0}
没有按预期工作.在 SOAPUI 中,这种表达式 ${=expression}
是作为 groovy 脚本执行的,所以实际上 SOAPUI 正在执行 !0
,结果为真,这是预期的结果.这就是 SOAPUI 抛出 replace...,期望 [true]
的原因.
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]
.
我认为最好将您的 XPath 表达式
更改为直接评估您的表达式是否为 >0
:
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
和预期的结果一样,只需设置 true
.
And as expected result simply set true
.
这篇关于将操作数 xpath 断言表达式与soapUI 中的预期结果进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!