Sign in Go Pro

Mockito

Mocking and Stubbing Final Classes

 

Up next

Previous

About

In this lesson, we'll explain how to configure Mockito so that it can mock or stub `final` classes. Historically, Mockito has never been able to produce test doubles for `final` classes, but that changed in a later version where it was introduced as an experimental _opt-in_ feature. This lesson will detail which Mockito version you'll need and how to configure this opt-in feature. #Summary of Content - Which version of Mockito is required to mock and stub final classes - Which exception you'll see if you attempt to use Mockito with a final class without first enabling the opt-in feature - How to add the Mockito MockMaker extension which enables Mockito to work with final classes - Showing an example test which successfully makes a test double of a final class #Other Relevant Links: - [Mockito.org](http://mockito.org/) - [What's new in Mockito 2](https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2#unmockable)

Lessons in Mockito