I think I got to understand [0] means. It’s because the string read from excel has extra 0 at the end i.e. 1.80 but the API response returns 1.8. That’s why using String compares fails.
In this case, if we use assertThat(x1).contains(x2) should work?
I tried convert the API response to Float using Floatparse, also doesn’t work. It will give me BigDecimal error.
Pls share the code … unable to say
Assert will also not work.
you have to print the Response via slurper
Response = WS.sendRequest(findTestObject(‘requestname’))
ResponseText = Response.getResponseText()
JsonSlurper slurper = new JsonSlurper()
Map parsedJson = slurper.parseText(ResponseText)
Then get both value in variable
def x1 = value of response
def x2 = value 2 from response
To verify
println(x1)
println(x2)
or another way to do check
def x = 1.08 as Double
def y = 7.12 as Double
print 'Sum of x + y = ' + (x + y).round(2)
//Then try this
assertThat(x1).contains(x2)