Skip to content
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

Mockito update/enhancements #384

Closed
nanodeath opened this issue May 1, 2021 · 2 comments · Fixed by #385
Closed

Mockito update/enhancements #384

nanodeath opened this issue May 1, 2021 · 2 comments · Fixed by #385

Comments

@nanodeath
Copy link
Contributor

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.

nanodeath added a commit to nanodeath/zircon that referenced this issue May 1, 2021
* Upgrade test library versions.
* Replace initMocks with JUnit rules.
* Use strict stubs.
* Replace "Mockito.`when`" with "whenever".
* Fix a couple tests that were broken.

Closes Hexworks#384.
nanodeath added a commit to nanodeath/zircon that referenced this issue May 1, 2021
* Upgrade test library versions.
* Replace initMocks with JUnit rules.
* Use strict stubs.
* Replace "Mockito.`when`" with "whenever".
* Fix a couple tests that were broken.

Closes Hexworks#384.
@Baret
Copy link
Collaborator

Baret commented May 1, 2021

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.

@nanodeath
Copy link
Contributor Author

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.

nanodeath referenced this issue in nanodeath/zircon May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants