Open semisiu opened 6 years ago
Good idea!
Hi folks, it would be cool
if you add information about type of expected and got objects
here
org.skyscreamer.jsonassert.JSONCompareResult#describe
because sometimes we got :
java.lang.AssertionError: id
Expected: 101
got: 101
in case of different types
This is one of a few issues about printing the actual objects that failed in more detail. This can blow up the results for people who have massive JSON sets, but I can see it being friendly for smaller sets. I'm less inclined to add extensions into the core methods, but I wonder if there is a pattern that we can recommend for test callers instead. Once you know the test fails, there are probably a variety of useful tools for printing out the entire JSON objects.
I support adding an option to make these assert messages more verbose (or at minimum, print out the whole jsons consecutively).
I'm using this library to verify that my Mongo queries are built correctly, and it's a lot easier to just compare the raw Mongo JSON side-by-side instead of trying to compare what keys are or aren't present between the two queries.
you are lucky that you have a diff and not just a generic error stack trace when they don't match :/
We'd like to have an ability to provide more verbose, or generally custom json diff view on assertion error (such like un*x
diff -y
does).For example, given two jsons:
and:
calling:
would throw an AssertionError with original message and additionally (optionally) more verbose diff:
More json-conscious diff: