如何使用Hamcrest检查集合是否包含给定顺序的项目
2022-08-31 20:36:12
如何使用Hamcrest检查给定的集合是否包含给定顺序的给定项目?我试过了,但它只是忽略了顺序。hasItems
List<String> list = Arrays.asList("foo", "bar", "boo");
assertThat(list, hasItems("foo", "boo"));
//I want this to fail, because the order is different than in "list"
assertThat(list, hasItems("boo", "foo"));