Missing recursive comparison assetions
SerVB opened this issue · comments
Hi! I'm comparing assertk to assertj and bumped into innability to find recursive comparison asserters.
Do they exist or are they not yet implemented?
IMO those are quite useful and powerful, and should be provided ootb.
Depends on what you mean, there's isDataClassEqualTo
that will check properties recursively, but that only works for data classes. Can you give an example of what exactly you are looking for?
Something like the following that we have with assertj now:
assertThat(actual)
.usingRecursiveComparison().ignoringFields(MyClass::myField.name)
.isEqualTo(expected)
It allows in this case:
- Ignoring some fields while comparing.
- Making collections equal if the elements inside are equal (so it's ok to have different types of collections).
In this case, it's indeed a data class, but I think a general comparison by all properties with backing fields should be also supported, like the support in assertj
ignoring fields is supported with isEqualToIgnoringGivenProperties