atrium icon indicating copy to clipboard operation
atrium copied to clipboard

hints for data classes if using toEqual

Open robstoll opened this issue 6 years ago • 1 comments

Platform (jvm, jdk8, js, android): all

Code related feature

expect(person).toBe(anotherPerson)

assuming Person is a data class. Currently one has to see the difference based on the representation of the two objects. It would be sweet if we compare the fields one by one and list those which do not match in the failure hint. Yet, only in the failure hint as one could override equals and we don't want to change this behaviour. We could even check if equals is overriden and warn the user.

robstoll avatar Sep 16 '19 09:09 robstoll

I like the proposal! But I think that this part:

We could even check if equals is overriden and warn the user.

is essential. Because with overridden equals, the fields reporting could be very confusing to the user.

jGleitz avatar Sep 16 '19 18:09 jGleitz