I've got a test that looks something like this:
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
private final List<String> expected = new ArrayList<String>("abc","xyz");
@Test
public void myTest() {
List<String> result = underTest();
assertThat(result, containsInAnyOrder(expected));
This test fails, because it expects result
to contain expected
. What I'm trying to do is test that result
contains each element in expected
. Is there a Matcher for this in hamcrest, or would I need to write one?