Mockito: Mockito:match any(Class<T>)

Created on 20 Mar 2017  路  2Comments  路  Source: mockito/mockito

Hey,

How I can match the Class, I want pass the method.

class A (){ public B method(Class T,String str){} }
when I invoice the Mockmethod,the method don't pass.
A a = new A(); B b = new B(); when(a.method(any<Class>).thenReturn(b);

Most helpful comment

Using any(Class.class) gives you the following warning by the compiler: Unchecked assignment: 'java.lang.Class' to 'java.lang.Class<java.lang.Object>'.

You can use this syntax instead:
ArgumentMatchers.<Class<A>>any()

All 2 comments

use any(CLass.class) is ok.

Using any(Class.class) gives you the following warning by the compiler: Unchecked assignment: 'java.lang.Class' to 'java.lang.Class<java.lang.Object>'.

You can use this syntax instead:
ArgumentMatchers.<Class<A>>any()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SylarChen picture SylarChen  路  3Comments

radsz picture radsz  路  5Comments

HonoluluHenk picture HonoluluHenk  路  4Comments

TimvdLippe picture TimvdLippe  路  5Comments

miaekim picture miaekim  路  5Comments