给定一个Collection或Iterable一个项目,是否有任何Matcher(或匹配的组合)断言每个项目匹配一个Matcher?
例如,给定此项目类型:
public interface Person {
public String getGender();
}
Run Code Online (Sandbox Code Playgroud)
我想写一个断言,Persons 集合中的所有项都有特定的gender值.我在想这样的事情:
Iterable<Person> people = ...;
assertThat(people, each(hasProperty("gender", "Male")));
Run Code Online (Sandbox Code Playgroud)
没有each自己编写匹配器,有没有办法做到这一点?