Few years ago, I used Unitils and I liked leniant assertions feature (= equals field by field using reflection).
Now, when at work, we are using a similar idea but implemented with a condition.
I think it could be a method on ObjectAssert.
For me, I propose 3 methods.
Imagining a Jedi object with name/lightsaber color
- Ignoring null
In yodaTemplate , the lightsaber color is null, so it field is ignore. The equals is just base on name.
Unitils considere default value are ignored. But I don't think it's a good idea. That's why, I think ignoring fields is better.
- Ignoring fields
The idea, is ignoring some fields.
isLenientEqualsToByIgnoringFields without fields params means completely equal.
- Accepting fields
The idea, is accepting some fields.
What do you think on this idea ?
I'am sure the methods name are the best and understandable for users.
I think it's not complicate to implements using PropertySupport.propertyValue (should be public in that way) and provide this method in AbstractAssert.
The 3 methods can delegate to only method on Objects with 3 params : info; actual, and kind of "LenientMatcher".
3 methods just use their own LenientMatcher
I can implements it. Not sure for M1, but soon.