1

I start off by extracting the 'amount' from the json response. (This is the originalBalance) After performing another action I then extract the 'amount' from another json response. (This is the newBalance).

I am then doing a match to check that the newBalance equals the originalBalance minus (from Examples) as shown here:

* def originalBalance = $response.giftCards[0].balanceAmount.amount
* def newBalance = $response.giftCards[0].balanceAmount.amount

And match newBalance == originalBalance - <amountToDeduct>
    
Examples:
     | amountToDeduct|
     | 0.01 |

Most times I run this it works fine. But other times it fails with a message similar to this:

match failed: EQUALS $ | not equal (NUMBER:NUMBER) 124.95 124.94999999999999

The two values that are being extracted from the json response are ok so there must be something going wrong with this line:

And match newBalance == originalBalance - <amountToDeduct>

Any idea what I am doing wrong?

Matt
  • 773
  • 2
  • 15
  • 30
  • I'm sorry I need a way to replicate this. it is possible there is some arithmetic weirdness in the new JS engine or more likely the routines you are using which are excluded from your example may be the culprit. please follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Jun 01 '22 at 17:48

0 Answers0