Mockito.any() pass Interface with Generics

前端 未结 7 1286
我在风中等你
我在风中等你 2020-11-29 16:26

is it possible to pass the type of an interface with generics?

The interface:

public interface AsyncCallback

In my test me

7条回答
  •  春和景丽
    2020-11-29 17:05

    I had to adopt the following mechamism to allow for generics:

    import static org.mockito.Matchers.any;
    List list = any();
    when(callMyMethod.getResult(list)).thenReturn(myResultString);
    

    Hope this helps someone.

提交回复
热议问题