Mockito cannot mock final classes in Kotlin

Cannot mock/spy class
Mockito cannot mock/spy because :
– final class

This happens because Kotlin classes and functions are declared as final/closed by default, but Mockito cannot mock/spy the object if it is a final class.

To resolve the above issue, you need to enable the option to mock the final classes in mockito. Which is to create a file and name it org.mockito.plugins.MockMaker in app/src/test/resources/mockito-extensions/ with this line



Search within Codexpedia

Custom Search

Search the entire web

Custom Search