我在使用 Specs2 和 Mockito 运行 Scala 单元测试时遇到问题。
val response = mock[Response]
"MyResource" should {
"handle NOT_FOUND from another WS" in {
response.status returns NOT_FOUND // Exception thrown here
anotherWS.getDetails("101010", "101") returns Future.successful(response)
.....
}
例外:
org.mockito.internal.invocation.Invocation.isToString(Lorg/mockito/invocation/InvocationOnMock;)Z
org.specs2.execute.Error$ThrowableException: NoSuchMethodError: org.mockito.internal.invocation.Invocation.isToString(Lorg/mockito/invocation/InvocationOnMock;)Z
Caused by: java.lang.NoSuchMethodError: org.mockito.internal.invocation.Invocation.isToString(Lorg/mockito/invocation/InvocationOnMock;)Z
at org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues.answer(ReturnsEmptyValues.java:59)
at org.mockito.internal.stubbing.defaultanswers.GloballyConfiguredAnswer.answer(GloballyConfiguredAnswer.java:24)
at org.mockito.internal.MockHandler.handle(MockHandler.java:99)
at org.mockito.internal.creation.MethodInterceptorFilter.intercept(MethodInterceptorFilter.java:47)