Add DeepEquals Assertion
Currently our codebase has a lot of nested objects and being able to deeply compare equality is important to making test debugging much easier. I'm wondering if there is a way to do this in Strikt? I tested out assertJ and they offer the following assertion to accomplish this.
assertThat(view.lastStateOrNull).isEqualToComparingFieldByFieldRecursively(
SubmitIDState(
fakeID,
ID(),
true
)
)
java.lang.AssertionError:
Expecting:
<SubmitIDState(id=ID(id=1d2f3s4f), confirmedID=ID(id=), isContinueButtonEnabled=false)>
to be equal to:
<SubmitIDState(id=ID(id=1d2f3s4f), confirmedID=ID(id=), isContinueButtonEnabled=true)>
when recursively comparing field by field, but found the following difference(s):
Path to difference: <isContinueButtonEnabled>
- actual : <false>
- expected: <true>
Is there a way to do this in strikt or will someone be adding support for this in the future?
Strikt has propertiesAreEqualTo which compares field by field but it doesn't do so recursively, only at the first level.
A recursive version would be tricky because many things that should probably be regarded as atomic values do expose bean type properties (the classes in java.time for example). If you have any ideas how that might work, let me know.
That's a good point regarding the atomic values. Let me take a look at propertiesAreEqualTo and see if that solves our current needs.