-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strictness warn fails tests #328
Comments
So you mean |
Yes, that's what I mean, at least as far as whether the tests pass or fail. I haven't exhaustively compared the output to know if there are differences in what is printed to the console or not. |
This could be due to the fact that mockito-scala is even stricter than mockito-core, so I may have missed something there, if you could please point me to one or two scenarios where it fails for you I can take a look and get it sorted |
When I run my test suite that has many tests with unexpected invocations, unused stubbing, or both, I get the same number of failures regardless of whether I set the Strictness of the session to Warn or StrictStubs.
I stepped through the code, and I think the problem is that
MockitoScalaSessionListener#reportIssues
is not checking the strictness. When the strictness is lenient, all the unexpected invocations have already been filtered out whenlistener.cleanLenientStubs
was called inMockitoScalaSession#finishMocking
, so the library behaves as expected in that case. But when the strictness is either Warn or Strict, they don't get filtered out, and they get reported as reasons to fail the test. For Strict this is good, but not for Warn.I was a little confused by this, because it seems like the
UniversalTestListener
is already handling reporting of unexpected invocations, in a way that either does nothing, warns, or fails the test, depending on strictness. I assume there's some reason for the apparent duplication in theMockitoScalaSessionListener
, but I'm not familiar enough with the architecture of the library to see why.I'm just getting started with upgrading an existing scala project from using a 2-year-old version of java mockito to the latest version of scala-mockito, so I'm still very new to these concepts.
The text was updated successfully, but these errors were encountered: