Skip to content

Usage of scalatest IdiomaticMockito produces "unfinished mocking session" errors #211

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
einholen opened this issue Mar 24, 2020 · 1 comment · Fixed by #213
Closed

Usage of scalatest IdiomaticMockito produces "unfinished mocking session" errors #211

einholen opened this issue Mar 24, 2020 · 1 comment · Fixed by #213

Comments

@einholen
Copy link
Contributor

einholen commented Mar 24, 2020

Hey Bruno!
I'm upgrading mockito-scala in my large project from 1.5.18 to 1.13.0 (and scalatest from 3.0.8 to 3.1.1 which is a big change). Scala 2.13.
All the tests in the project derive from org.mockito.scalatest.IdiomaticMockito. After upgrading and fixing all compile errors, when I run all tests, about 700 of them pass, and suddenly, after a certain point, every single test starts failing with this:

[info]   org.mockito.exceptions.misusing.UnfinishedMockingSessionException: Unfinished mocking session detected.
[info] Previous MockitoSession was not concluded with 'finishMocking()'.
[info] For examples of correct usage see javadoc for MockitoSession class.

And then obviously whichever of the failed tests I rerun manually, they pass.
Feels like something somewhere sets a static state and doesn't unset it - or perhaps there is a race condition. The project has parallelExecution in Test := false though...

Any ideas what it could be?
Could it be the fact that MockitoSessionFixture doesn't catch exceptions? I haven't been able to figure out the exact trigger for the failures but suspect it can start after a normal test failure.
Just letting you know in case you have ideas, but I'll investigate more.

@einholen
Copy link
Contributor Author

einholen commented Mar 24, 2020

Ok, further investigation showed that one of the test suites got aborted because of a StackOverflowError, and that caused all subsequent MockitoScalaSession-based test cases to fail with the error above

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant