How to compare LISTS recursively ignoring given fields using assertJ?

orrymr picture orrymr · Jun 22, 2017 · Viewed 7k times · Source

Firstly, this is not a duplicate of this question. There, it is asked specifically for an object. I want to do this for a Container, specifically a List.

So, I know I can ignore a field when using usingElementComparatorIgnoringFields() But this won't do a recursive comparison.

I know I can use usingRecursiveFieldByFieldElementComparator(). But this will not allow me to exclude a given field.

How can I compare recursively, ignoring a field?

Answer

Joel Costigliola picture Joel Costigliola · Jun 23, 2017

this is going to be in the next AssertJ Core version: https://github.com/joel-costigliola/assertj-core/issues/1002