public class Cache {
(...)
public void removeAllIf(Predicate<Product> predicate) {
(...)
}
}
我打电话给
productsCache.removeAllIf(Product::isChecked);
现在我用
then(productsCache).should().removeAllIf(any(Predicate.class));
但这并不准确(如果通过的lambda是
Product::isChecked
). 第二个问题是,我得到了lint消息:
未检查的分配
.
编辑:
我不想测试
removeAllIf
去除
是有正当理由的。
要测试的场景:
public class Repository {
public void removeCheckedProducts() {
remoteDataSource.removeCheckedProducts();
localDataSource.removeCheckedProducts();
cache.removeAllIf(Product::isChecked);
}
}
@Test
public void removeCheckedProducts() {
//when
repository.removeCheckedProducts();
//then
then(remoteDataSource).should().removeCheckedProducts();
then(localDataSource).should().removeCheckedProducts();
then(cache).should().removeAllIf(any(Predicate.class));
}