-
-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertThat(actual).usingRecursiveComparison().ignoringAllOverriddenEquals().isEqualTo(expected) does not verify fields in a parent class #1815
Comments
Thanks for reporting this, I'm going to have a look at it shortly. |
Thanks for the prompt response.
May I ask why there is such a limitation? |
Awesome investigation @VasilyV, appreciated. The reason was to avoid base types to be compared field by field, at some point you have to compare stuff normally. In your case if we did not do that we would for example compare |
@joel-costigliola Thank you for the nice explanation! |
You can always use a specific comparator for a given type or field if you need to, see https://assertj.github.io/doc/#assertj-core-recursive-comparison-comparators |
See also #1224 (seems to be a duplicate) |
Closing since an explanation has been given. |
Summary
I've come across an interesting behavior of recursive comparison in assertj library. If you compare objects of classes that are sub-classes, fields of super classes seem to be skipped during the comparison. Is that a known issue? Or am I doing something wrong? Here is a brief example:
Example
This test will pass when actually it should not as
actual.getMessage()
andexpected.getMessage()
will return different values.The text was updated successfully, but these errors were encountered: