2017-01-30 52 views
0

我有屬性,它的值是21.0有時我需要斷言是21.0,有時是21了SoapUI斷言失敗驗證雙到INT

我有xpath: //Results/ResultSet/Row[@rowNumber="1"]/KI_VALUE 我想我的結果顯示:

<KI_VALUE>21</KI_VALUE> 

我預期的結果:${#TestCase#VALUE1}這給了我21.0。我怎麼能捨它是21?當我試圖把圓它提到它,因爲它是字符串輸出的一部分功能。

+0

meitale,請檢查答案,看看是否是有幫助的。 – Rao

回答

0

您應該能夠使用XPath的starts-with功能,以便它可以匹配所有的初始值。

了SoapUI屬性被讀取爲字符串值,所以不能使用round功能。

XPath的斷言道:

定義的XPath斷言爲:

starts-with(//Results/ResultSet/Row[@rowNumber="1"]/KI_VALUE, ${#TestCase#VALUE1}) 

並運用期望值爲true

如果你想用數字來匹配它,那麼你可以使用Script Assertion因此,它可以在數學比較。

腳本斷言道:

import com.eviware.soapui.support.XmlHolder 
def xml = new XmlHolder(context.response) 
//change the xpath as per the need 
def responseValue = xml.getNodeValue("//Results/ResultSet/Row[@rowNumber="1"]/KI_VALUE") as Double 
//change the property name as needed 
def expectedValue = context.testCase.getPropertyValue('VALUE1') as Double 

assert expectedValue == responseValue, "Both actual and expected KI_VALUE are not matching"