JUnit 4 compare Sets

后端 未结 9 1180
-上瘾入骨i
-上瘾入骨i 2020-12-24 03:59

How would you succinctly assert the equality of Collection elements, specifically a Set in JUnit 4?

9条回答
  •  暖寄归人
    2020-12-24 04:53

    with hamcrest:

    assertThat(s1, is(s2));
    

    with plain assert:

    assertEquals(s1, s2);
    

    NB:t the equals() method of the concrete set class is used

提交回复
热议问题