You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected the resulting message to contain the expected value def456.
Instead the output looks like this:
JSON documents are different:
Matcher "exampleMatcher" does not match value "abc123" in node "someText". was "abc123"
Notice the . was "abc123" at the end, which just repeats the actual 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:
Didn't look too deep into the Matcher interface, but looking at existing Hamcrest Matchers it seems like matcher.describeMismatch(value, description) only populates the description with the actual value.
Possible solution
Calling matcher.describeTo(description) between lines 36 and 37, mentioned above, should allow the Hamcrest Matcher to populate the description with the expected value, although I must admit, the formatting looks a little funky due to a missing space character:
JSON documents are different:
Matcher "exampleMatcher" does not match value "abc123" in node "someText". "def456"was "abc123"
The text was updated successfully, but these errors were encountered:
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: