java – Generic assertThat(ArrayList,hasItems(InstanceOfSomeInterface))不工作

我想使用Hamcrest的hasItems和一个“实际”集合,它是一个ArrayList<?扩展SomeInterface>

assertthat(ArrayList

编译器说:

The method assertthat(T,Matcher in the type Assert is not applicable for the arguments (ArrayListterable

出了什么问题?我该怎么办(我真的想在这里使用Hamcrest)?

最佳答案
ArrayListassertthat(newList,hasItems(InstanceOfSomeInterface));

不幸的是Assert.assertthat没有编码使用?超级还是?扩展到允许你描述的内容.

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...