Skip to content
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

Missing recursive comparison assetions #430

Open
SerVB opened this issue Dec 2, 2022 · 3 comments
Open

Missing recursive comparison assetions #430

SerVB opened this issue Dec 2, 2022 · 3 comments

Comments

@SerVB
Copy link

SerVB commented Dec 2, 2022

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.

@evant
Copy link
Collaborator

evant commented Nov 30, 2023

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?

@SerVB
Copy link
Author

SerVB commented Dec 1, 2023

Something like the following that we have with assertj now:

assertThat(actual)
      .usingRecursiveComparison().ignoringFields(MyClass::myField.name)
      .isEqualTo(expected)

It allows in this case:

  1. Ignoring some fields while comparing.
  2. 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

@evant
Copy link
Collaborator

evant commented Dec 1, 2023

ignoring fields is supported with isEqualToIgnoringGivenProperties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants