使用 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:使用泛型参数进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!