我目前有一個斷言腳本,匹配從設置值的響應值。見下文: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