我正在尝试将Scala系统移植到Mockito2。有一些使用doReturn
的测试用例,现在在Mockito 2.18.0
中出现此错误:
Error:(34, 5) ambiguous reference to overloaded definition,
both method doReturn in object Mockito of type (x$1: Any, x$2: Object*)org.mockito.stubbing.Stubber
and method doReturn in object Mockito of type (x$1: Any)org.mockito.stubbing.Stubber
match argument types (com.twitter.util.Future[Unit])
doReturn(Future.Unit).when(f.adapterSpy).myFunction(userData, Some(offerId), Always)
查看
Mockito.java
,doReturn
确实像这样重载:public static Stubber doReturn(Object toBeReturned)
public static Stubber doReturn(Object toBeReturned, Object... toBeReturnedNext)
这在地球上怎么不总是模棱两可?如何进行编译?
谢谢
最佳答案
Scala积压中有一张票。见https://github.com/scala/bug/issues/4775