How would you succinctly assert the equality of Collection elements, specifically a Set in JUnit 4?
You can assert that the two Sets are equal to one another, which invokes the Set equals() method.
public class SimpleTest {
private Set setA;
private Set setB;
@Before
public void setUp() {
setA = new HashSet();
setA.add("Testing...");
setB = new HashSet();
setB.add("Testing...");
}
@Test
public void testEqualSets() {
assertEquals( setA, setB );
}
}
This @Test will pass if the two Sets are the same size and contain the same elements.