我目前有一个断言脚本,匹配从设置值的响应值。见下文:SoapUI断言匹配任何一方0.05内的字段值
// get the xml response
def response = messageExchange.getResponseContent()
// parse it
def xml = new XmlSlurper().parseText(response)
// find your node by name
def node = xml.'**'.find { it.name() == 'total-premium' }
// assert
assert node.toString().matches("(0|27.11|0)\\d*"), 'Expected Result: 0 or 27.11 or 0 Actual Result: ' + node
我想要做的是匹配0.05以下和以上的值之间的值。所以对于这个特定的脚本,如果total-premium
的值在27.06到27.16之间,我需要断言是真的。
此刻,断言代码将字段total-premium
中的数值与matches("(0|27.11|0)\\d*")
中的三个值相匹配。
但是,代替我输入11个值total-premium
可能是我希望行assert node.toString().matches("(0|27.11|0)\\d*"), 'Expected Result: 0 or 27.11 or 0 Actual Result: ' + node
通过即使字段中的值是0.05加上或减去我手动输入到此脚本中的值。对于这个例子是27.11
。
有关简要概述,我有〜1000个测试用例,我使用Excel为每个测试用例创建代码和断言,然后导入到SoapUI中。所以我根据Excel算法输入的值自动匹配脚本。
你能显示什么是你的断言的输入和发生了什么?目前尚不清楚。 – Rao