I found a solution for JUnit but couldn't find for TestNG.
Asked
Active
Viewed 2,114 times
1

Maciej Kowalski
- 25,605
- 12
- 54
- 63

Michał Szewczyk
- 7,540
- 8
- 35
- 47
-
Alternatively shouldn't just the [following assertEquals](https://jitpack.io/com/github/cbeust/testng/master-6.12-g0ef9cdb-153/javadoc/org/testng/Assert.html#assertEquals-java.util.Collection-java.util.Collection-) suffice for comparison - `assertEquals(list1,list2);` ? `Object` comparison. – Naman Nov 02 '17 at 02:17
-
and do you actually need testng to do it? I like this [solution](https://stackoverflow.com/a/22807363/1746118) instead the most. – Naman Nov 02 '17 at 04:07
1 Answers
6
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

Maciej Kowalski
- 25,605
- 12
- 54
- 63