mockserver icon indicating copy to clipboard operation
mockserver copied to clipboard

Integer, Double and String with the same value to be considered the same value

Open Rafaelxpxpxp opened this issue 3 years ago • 1 comments

Description

Sometimes we test more than one system with the same mock and some script languages can allow you to use double and integers on the same field while typed language does not allow it. Sometimes we want to 1.0 to be equals to 1 but at moment mock server does not allow comparation ignoring the type of the field

What you are trying to do I have a test failler on java that works on groovy where the expectation for a field is 1 but the field allows double values so java send the request as 1.0 what makes the test fails

The solution you'd like Allow 1, 1.0 , "1" and "1.0" to be consider equals for the expectations with a configuration to enable it

Describe alternatives you've considered The only way I found to solve this is to create a new expectation with the converted value for the type double or integer

Rafaelxpxpxp avatar Jun 01 '22 18:06 Rafaelxpxpxp

This behavior changed with 5.10 and the switch to JSONUnit. There is a way to configure JSONUnit to compare those numbers, as far as I understand, but it's not exposed by mockserver.

therve avatar Jun 15 '22 12:06 therve