Michał Szewczyk
Michał Szewczyk

Reputation: 8168

TestNG - How to assert that two lists are equal ignoring order?

I found a solution for JUnit but couldn't find for TestNG.

Upvotes: 1

Views: 2641

Answers (1)

Maciej Kowalski
Maciej Kowalski

Reputation: 26522

There is no equivalent as good as found in the Hamcrest library but you could transform each of the lists to an array and the use:

public static void assertEqualsNoOrder(Object[] actual,
                                       Object[] expected)

as per javadoc:

Asserts that two arrays contain the same elements in no particular order

Upvotes: 6

Related Questions