Mockito update/enhancements
nanodeath opened this issue · 2 comments
This is an admin task, but...Zircon's using Mockito 1.x (1.10.19), which was last updated in 2014. Mockito 3.x is available now. Mockito 2.x had a lot of enhancements, but the main thing of interest to me is strict stubs, which makes for higher-quality tests. We also don't seem to be leveraging the Mockito-kotlin module everywhere.
So:
- Upgrade to Mockito 3.x
- Activate strict stubs
- Switch to using Mockito's JUnit Rule instead of calling
initMocks(this)
- Use
whenever
instead of "Mockito.when
"
Also, FWIW, Mockito is used very little in this codebase; just UIEventToComponentDispatcherTest
and DefaultAnimationRunnerTest
, so this shouldn't be a big change.
As we are in a kotlin project I'd like to suggest to switch to MockK entirely.
When you need to touch all tests anyways, it shouldn't be much more work I guess.
My experience with mockk so far is that is a charm to work with and much much better than mockito.
mockito-kotlin
works fine except for things like coroutines or objects
, which we're not making heavy use of. I agree that mockk
is better than mockito-kotlin
, but it's also more effort to switch.