Reputation: 127
I have a test case where I have defined some custom properties for just performing an addition operation. Now I want to assert that the result is actually equal to the sum of both inputs. I wrote a groovy script for it to validate and log the two inputs and did a comparison check.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( messageExchange.responseContent )
holder.namespaces["ns"] = "http://tempuri.org/"
def conversionRate = holder.getNodeValue("//ns:AdditionResult")
log.info messageExchange.modelItem.testStep.testCase.getPropertyValue("operand1").toInteger()
log.info messageExchange.modelItem.testStep.testCase.getPropertyValue("operand2").toInteger()
log.info conversionRate
log.info messageExchange.modelItem.testStep.testCase.getPropertyValue("operand1").toInteger() + messageExchange.modelItem.testStep.testCase.getPropertyValue("operand2").toInteger() == conversionRate
When I execute it logs the following:
Sun Mar 13 15:22:53 IST 2016:INFO:122
Sun Mar 13 15:22:53 IST 2016:INFO:12
Sun Mar 13 15:22:53 IST 2016:INFO:134
Sun Mar 13 15:22:53 IST 2016:INFO:false
It's giving me false instead of true. Shouldn't it be true instead of false?
Upvotes: 1
Views: 99
Reputation: 84844
Is conversionRate
an integer as well?
def i = '122'.toInteger()
def j = '12'.toInteger()
def rate = '134'
println i + j == rate
println i + j == rate.toInteger()
Upvotes: 2