Is there a Hamcrest “for each” Matcher that asserts all elements of a Collection or Iterable match a single specific Matcher?

后端 未结 2 573
渐次进展
渐次进展 2021-01-01 08:06

Given a Collection or Iterable of items, is there any Matcher (or combination of matchers) that will assert every item matches a singl

2条回答
  •  情深已故
    2021-01-01 08:51

    IMHO this is much more readable:

    people.forEach(person -> Assert.assertThat(person.getGender()), Is.is("male"));
    

提交回复
热议问题