如何在SoapUI断言中检查非此数字 [英] How to check for NOT this number in SoapUI Assertion

查看:144
本文介绍了如何在SoapUI断言中检查非此数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些Soap UI测试,并试图弄清楚是否可以使用正则表达式来检查不包含特定数字的字符串.在这种情况下,我想确保当我得到一个响应时,我的recordCount字段不包含0.我认为这可能会更容易,但是当我可以看到一种检查一组数字的方式时,可以使用正则表达式来避免这种情况.似乎不起作用.可能只检测字符而不检测数字.

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.

我的XML包含以下内容:

My XML contains this:

<recordCount>0</recordCount>

我想要的是类似的东西

recordCount>[^0]

所以我可以确保在响应中显示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?

编辑:使用SiKing的答案,我只是使用了NotContains查找recordCount> 0;这涵盖了两种情况,在这些情况下,我不仅仅查找返回了多少记录的特定数据,在这些情况下,它们只需要大于0

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

推荐答案

为什么必须是正则表达式?

Why does it have to be regular expression?

您可以使用以下XPath断言之一,所有这些断言的预期结果都是false:

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

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

这篇关于如何在SoapUI断言中检查非此数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆