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 ?
You need to assert something for
eventually,successis a good case for that, as before theverifywill fail withAssertionErrorwhen it was not called.In case you want to be more explicit on that, you can do something like this (based on this issue):