mocking a method that return generics with wildcard using mockito

前端 未结 2 1926
盖世英雄少女心
盖世英雄少女心 2020-12-08 06:18

I\'m using mockito 1.9.5. I have the following code:

public class ClassA  {

public List getMyInterfaces() {
    return null;
}         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 06:52

    Another solution (albeit less readable) is to qualify the static method call of when to bind the wildcard:

    Mockito.>when(classAMock.getMyInterfaces()).thenReturn(interfaces);
    

提交回复
热议问题