使用 Mockito,我可以做到以下几点:
With Mockito I can do the following:
verify(someService).process(any(Person.class));
但是,如果 process 采用 Collection 代替,我该怎么写呢?无法弄清楚如何正确编写它.只是遇到语法错误...
But how do I write this if process takes a Collection<Person> instead? Can't figure out how to write it correctly. Just getting syntax errors...
试试:
verify(someService).process(Matchers.<Collection<Person>>any());
实际上,当我键入 any() 时,IntelliJ 会自动建议此修复程序...不幸的是,在这种情况下您不能使用静态导入.
Actually, IntelliJ automatically suggested this fix when I typed any()... Unfortunately you cannot use static import in this case.
这篇关于Mockito:使用泛型参数进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)