Forum Discussion

NehaLadani's avatar
Occasional Contributor
2 years ago

Regarding rounding function

I would like to add rounding function in my assertions

[Match content of [xyz]] Comparison failed. Path: [$['xyz']]; Expected value: [5.461*]; Actual value: [5.46076854].

Expected value: [5.461*] is in ExcelQATestfile (Excel file cannot be modified)
Actual value: [5.46076854]  is API output 

So, I am looking for a solution that will make my readyapi assertion force Actal value  to rounding and I get Expected  = Actual

Please help me..

1 Reply

  • groovyguy's avatar
    Champion Level 1

    Do you know if the amount of significant digits required will always be the same? IE, in the example you gave, the Excel spreadsheet shows 3 significant digits and *.  If they'll always be the same this may be easy to handle.


    What type of assertion are you using? That'll define a way forward. In my experience, I am not sure an XPATH statement can handle this, but a custom groovy script possibly could.