I am writing a test with specs2 and mockito in Scala. The test should verify that a function foo
running asynchronously calls barMock.bar()
In order to verify the barMock.bar()
call I can use verify
:
verify(barMock).bar()
Since foo
is running asynchronously I should use eventually
method to verify the call :
eventually {
verify(barMock).bar()
}
Unfortunately, the code above does not compile and I had to add success
eventually {
verify(barMock).bar()
success
}
Is it possible to get rid of that successs
?
CodePudding user response:
You need to assert something for eventually
, success
is a good case for that, as before the verify
will fail with AssertionError
when it was not called.
In case you want to be more explicit on that, you can do something like this (based on this issue):
eventually {
verify(barMock).bar() must not(throwA[AssertionError])
}