Mockito match any class argument

后端 未结 5 1978
忘了有多久
忘了有多久 2020-12-22 18:48

Is there a way to match any class argument of the below sample routine?

class A {
     public B method(Class a) {}
}

How

5条回答
  •  旧巷少年郎
    2020-12-22 19:46

    How about:

    when(a.method(isA(A.class))).thenReturn(b);
    

    or:

    when(a.method((A)notNull())).thenReturn(b);
    

提交回复
热议问题