java - 断言集合不包含项目

标签 java hamcrest

使用 Java 的 hamcrest 库,什么是一种很好的可读方式来做相反的事情:

assertThat(someCollection, hasItem(someItem))

我想确保 someCollection 不包含项目 someItem

最佳答案

否定 hasItem 断言

assertThat(someCollection, not(hasItem(someItem)))

关于java - 断言集合不包含项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9355568/

相关文章:

java - 如何表示参数值在 JUnit 测试中无关紧要?

java - 获取数组中所有可能的字符组合

java - 如何获得唯一的方法标识符?

java - BOX2D - 将 NULL 常量隐式转换为 'bool' [-Wnull-conversion]

java - Hamcrest:比较两个自定义类对象集合

java - Hamcrest 泛型 hell #2 : iterableWithSize gives errror "is not applicable for the arguments"

java - 如何使用 to_char 函数按条件添加到 Criteria 订单

java - 使用随机 int 的 ArrayIndexOutOfBoundsException

java - 使用 Hamcrest 检查某些元素是否在集合中

java - 通过 RestAssured 在 JSON 中进行多个匹配断言