Mockito.any() pass Interface with Generics
There is a type-safe way: use ArgumentMatchers.any()
and qualify it with the type:
ArgumentMatchers.<AsyncCallback<ResponseX>>any()
Using Java 8, you can simply use any()
(assuming static import) without argument or type parameter because of enhanced type inference. The compiler now knows from the target type (the type of the method argument) that you actually mean Matchers.<AsyncCallback<ResponseX>>any()
, which is the pre-Java 8 solution.