You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 1.17.12 of mockito-scala we have a strange behavior.
The method "simpleMethod" is really call.
If we launch the tests "with Spied", the temporary file is created and the method throw "java.lang.ArithmeticException: / by zero". On the contrary the test "with Mock" doesn't have problem.
I don't understand why ? It looks as a bug.
I also encountered a similar issue with this code:
classRunnerTestextendsAnyFlatSpecwithIdiomaticMockito {
"runner" should "expire snapshots" in {
valmockRedis= mock[Redis]
valsvc=newService(mockRedis, null, null)
valmockService:Service= spy(svc ,lenient =true)
when(mockService.someMethod("db", "table")).thenReturn(()) // this line fails with java.lang.NullPointerException was thrown and the stack shows that the actual method was called
}
}
Yeah, I have the same error here. Have you found a workaround for it?
edit: This is not an error, this is the expected behaviour for spies on Mockito. This stack overflow answer has a good explanation about it: https://stackoverflow.com/a/11620196
In this case we should use mockito's doReturn syntax, that mockito-scala translate this way: doReturn("mocked!").when(aMock).bar <=> "mocked!" willBe returned by aMock.bar
Using @sushi30 example, () willBe returned by mockService.someMethod("db", "table") will work
Hello
In 1.17.12 of mockito-scala we have a strange behavior.
The method "simpleMethod" is really call.
If we launch the tests "with Spied", the temporary file is created and the method throw "java.lang.ArithmeticException: / by zero". On the contrary the test "with Mock" doesn't have problem.
I don't understand why ? It looks as a bug.
The text was updated successfully, but these errors were encountered: