我找到了一个 solution 对于JUnit,但找不到用于TestNG的。
没有比Hamcrest库中更好的等效项,但您可以将每个列表转换为一个数组,并使用:
public static void assertEqualsNoOrder(Object[] actual, Object[] expected)
根据javadoc:
断言两个数组不特定地包含相同的元素 顺序