Mock final classes and methods
Introduction#
Since Mockito 2.x we have the ability to mock final classes and methods.
How to make it
Steps:
-
Add dependency to Mockito version 2.x in your
gradle
(at the time of writing this text the latest version is 2.7.22):testCompile "org.mockito:mockito-core:$versions.mockito"
-
Create a file in test resources with name
org.mockito.plugins.MockMaker
:
-
Add next line in this file:
mock-maker-inline