What to Use Instead of Assertj isEqualToIgnoringGivenFields?

This method seems to be Deprecated. I would really appreciate it if you could tell me what AssertJ advises to use instead.

0

1 Answer

As mentioned in the javadoc:

Use the recursive comparison by calling usingRecursiveComparison() and chain with ignoringFields(String...).

This method is deprecated because it only compares the first level of fields while the recursive comparison traverses all fields recursively (only stopping at java types).

assertThat(oneObject)
    .usingRecursiveComparison()
    .ignoringFields("fieldToIgnore")
    .isEqualTo(anotherObject);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest