-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
When asserting on lists of objects with very long string representations, it can be quite difficult to see what differs between the actual and expected values.
assertThat(someList).containsExample(a, bunch, of, big, objects)
If there's an error, this will print out something like
expected to contain exactly:<[ReallyBigObject(a=0,b=1,c=2...), ReallyBigObject(a=3,b=4,c=5...)]> but was:<[ReallyBigObject(a=0,b=1,c=2...), ReallyBigObject(a=2,b=4,c=5...)]>
I usually end up copying and pasting the two values and putting them on separate lines or using the IDE's compare feature to see the difference. It'd be much easier to compare them visually if they were printed on separate lines:
expected to contain exactly:
[ReallyBigObject(a=0,b=1,c=2...), ReallyBigObject(a=3,b=4,c=5...)]
but was:
[ReallyBigObject(a=0,b=1,c=2...), ReallyBigObject(a=2,b=4,c=5...)]
One way to get around this is to sidestep the list assertion altogether and just compare each item individually but that's sort of annoying.
Metadata
Metadata
Assignees
Labels
No labels