使用 Java 的 hamcrest 库,什么是一种很好的可读方式来做相反的事情:
assertThat(someCollection, hasItem(someItem))
我想确保 someCollection
不包含项目 someItem
最佳答案
否定 hasItem
断言
assertThat(someCollection, not(hasItem(someItem)))
关于java - 断言集合不包含项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9355568/