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

isEqualToComparingFieldByFieldRecursively lacks "Path to difference" when comparing Maps #1303

Closed
mindhaq opened this issue Aug 23, 2018 · 3 comments
Milestone

Comments

@mindhaq
Copy link

mindhaq commented Aug 23, 2018

Summary

When two java.util.Map objects are compared with isEqualToComparingFieldByFieldRecursively, and one of the keys has a different value, the error message is not showing which key has the wrong value. It displays Path to difference: <>.

Example

@Test
void compareMaps() {
    var map1 = Map.of("k1", "v1");
    var map2 = Map.of("k1", "different");

    assertThat(map1).isEqualToComparingFieldByFieldRecursively(map2);
}

Resulting message:

java.lang.AssertionError: 
Expecting:
  <{"k1"="v1"}>
to be equal to:
  <{"k1"="different"}>
when recursively comparing field by field, but found the following difference(s):

Path to difference: <>
- actual  : <"v1">
- expected: <"different">
@joel-costigliola
Copy link
Member

Good catch, thanks for reporting this !

@joel-costigliola joel-costigliola added this to the 3.12 milestone Aug 23, 2018
@joel-costigliola
Copy link
Member

Will be part of #1002 (new recursive comparison api).

@joel-costigliola
Copy link
Member

Will be part of #1002 (new recursive comparison api).

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