Sometimes when writing unit tests, we need to make order agnostic comparison of lists. In this short tutorial, we’ll take a look at different examples of how we can write such unit tests.
As per the List#equals Java documentation, two lists are equal if they contain the same elements in the same order. Therefore we can’t merely use the equals method as we want to do order agnostic comparison.
#java collections #testing #assertj #junit