-
-
Notifications
You must be signed in to change notification settings - Fork 749
Closed
Labels
theme: recursive comparisonAn issue related to the recursive comparisonAn issue related to the recursive comparison
Milestone
Description
Source: #2115 (comment)
Example
Map<String, Object> mapA = Map.of("foo", "bar",
"description", "foobar",
"submap", Map.of("subFoo", "subBar", "description", "subFooBar"));
Map<String, Object> mapB = Map.of("foo", "bar",
"description", "barfoo",
"submap", Map.of("subFoo", "subBar"));
// should work but fails
assertThat(mapA).usingRecursiveComparison()
.ignoringFields("description", "submap.description")
.isEqualTo(mapB);
assertThat(mapA).usingRecursiveComparison()
.ignoringFieldsMatchingRegexes(".*description")
.isEqualTo(mapB);
java.lang.AssertionError:
Expecting actual:
{"description"="foobar", "foo"="bar", "submap"={"description"="subFooBar", "subFoo"="subBar"}}
to be equal to:
{"description"="barfoo", "foo"="bar", "submap"={"subFoo"="subBar"}}
when recursively comparing field by field, but found the following difference:
field/property 'submap' differ:
- actual value : {"description"="subFooBar", "subFoo"="subBar"}
- expected value: {"subFoo"="subBar"}
actual and expected values are maps of different size, actual size=2 when expected size=1
Metadata
Metadata
Assignees
Labels
theme: recursive comparisonAn issue related to the recursive comparisonAn issue related to the recursive comparison