Wrapping Up

In this chapter, we covered a few of the newer capabilities of Mockito, namely, how to mock final classes and methods and static methods. We looked at the @MockBean annotation provided by the Spring Framework that creates a mock and replaces any existing instance in the application context.

Finally, we used our Astro project to uncover reasons for the recommendation from the Mockito team to not mock types you don’t own.

Hopefully you now feel ready to use Mockito as it was intended—to make your unit tests more robust, reliable, and helpful.

Get Mockito Made Clear now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.