Mockito match any class argument
Two more ways to do it (see my comment on the previous answer by @Tomasz Nurkiewicz): The first relies on the fact that the compiler simply won’t let you pass in something of the wrong type: when(a.method(any(Class.class))).thenReturn(b); You lose the exact typing (the Class<? extends A>) but it probably works as you need it to. … Read more