相关疑难解决方法(0)

如何使用Hamcrest检查集合是否包含给定顺序的项目

如果给定的集合包含给定顺序的给定项目,如何使用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)

java collections hamcrest

42
推荐指数
2
解决办法
5万
查看次数

标签 统计

collections ×1

hamcrest ×1

java ×1