-
Notifications
You must be signed in to change notification settings - Fork 115
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
Failing Hamcrest Matcher does not print expected value #820
Comments
lukas-krecan
added a commit
that referenced
this issue
Oct 10, 2024
Hi, thanks for report. You are right, this should fix it |
lukas-krecan
added a commit
that referenced
this issue
Oct 10, 2024
lukas-krecan
added a commit
that referenced
this issue
Oct 10, 2024
lukas-krecan
added a commit
that referenced
this issue
Oct 10, 2024
Released as 3.5.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently using
json-unit-core:3.4.1
, facing incomplete output on test failure when using a Hamcrest Matcher as a custom Matcher.Problem
Given the following assertion:
I expected the resulting message to contain the
expected
valuedef456
.Instead the output looks like this:
Notice the
. was "abc123"
at the end, which just repeats theactual
value again.This can be highly confusing as there is no information in the message, what the
expected
value was.Cause
This happens due to a missing call between these two lines:
JsonUnit/json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/HamcrestHandler.java
Lines 36 to 37 in 16eb5c2
Didn't look too deep into the
Matcher
interface, but looking at existing Hamcrest Matchers it seems likematcher.describeMismatch(value, description)
only populates the description with theactual
value.Possible solution
Calling
matcher.describeTo(description)
between lines 36 and 37, mentioned above, should allow the Hamcrest Matcher to populate the description with theexpected
value, although I must admit, the formatting looks a little funky due to a missing space character:The text was updated successfully, but these errors were encountered: