Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison of jsons (with tolerance) fails for numbers, when any option is provided #51

Closed
priyesh25 opened this issue Dec 22, 2016 · 2 comments

Comments

@priyesh25
Copy link

Passes:
JsonAssert.setTolerance(0.01);
assertJsonEquals("{"test":1}", "{"test":1.009}");

Passes:
assertJsonEquals("{"test":1}", "{"test":1,"extra":2323}", when(IGNORING_EXTRA_FIELDS));

Fails:
JsonAssert.setTolerance(0.01);
assertJsonEquals("{"test":1}", "{"test":1.009}", when(IGNORING_EXTRA_FIELDS));

Combining withTolerance and when Option fails.

@lukas-krecan
Copy link
Owner

Hi, thanks for feedback. JsonAssert.setTolerance(0.01) is an obsolete static configuration which get's overriden be local configuration provided by "when". You can set tolerance locally by using when(..).withTolerance(..) or you can set IGNORING_EXTRA_FIELDS globally by JsonAssert.setOptions(). I admit it's a bit confusing but it's hard to change due to backward compatibility.

@priyesh25
Copy link
Author

Thanks for the response. So its either both (tolerance and options) global or both local.
Going with both global for now. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants