-
-
Notifications
You must be signed in to change notification settings - Fork 749
Closed
Description
Feature summary
Often times, classes define specialized equality methods that have different semantics than Object#equals
. It would be nice to be able to reference these directly via a BiPredicate<T, T>
and have it work with isEqualTo
and other relevant methods.
Example
assertThat(actual)
.usingEqualityMethod((x, y) -> x.equalsStrict(y))
.isEqualTo(expected);
// or
assertThat(actual)
.usingEqualityMethod(MyObject::equalsStrict)
.isEqualTo(expected);
I can currently hack around this by (ab)using usingComparator
, but it's not ideal.
assertThat(actual)
.usingComparator((x, y) -> x.equalsStrict(y) ? 0 : -1)
.isEqualTo(expected)
Metadata
Metadata
Assignees
Labels
No labels