JUnit 4 compare Sets

后端 未结 9 1191
-上瘾入骨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 05:03

    Check this article. One example from there:

    @Test  
    public void listEquality() {  
        List expected = new ArrayList();  
        expected.add(5);  
    
        List actual = new ArrayList();  
        actual.add(5);  
    
        assertEquals(expected, actual);  
    }  
    

提交回复
热议问题