我有一个看起来像这样的测试:
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));
该测试失败,因为它期望result
包含expected
。我想做的是测试result
包含 {em> expected
中的每个元素。 hamcrest中有匹配器吗?还是我需要写一个匹配器?