How to mock generic method in Java with Mockito?

前端 未结 3 2272
生来不讨喜
生来不讨喜 2021-02-15 17:09

How can we mock the IRouteHandlerRegistry? The error is Cannot resolve method thenReturn(IHandleRoute)

public interfac         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-02-15 17:50

    Mockito.when argument should be a method not a mock.

    The correct statement is: when(registry.getHandlerFor (route)).thenReturn(handler)

提交回复
热议问题