如果给定的集合包含给定顺序的给定项目,如何使用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"));
Run Code Online (Sandbox Code Playgroud)