Writing test cases for my Android code. I am trying to mock a enum & change behaviour of enum method. I heard that Mockito 2 supports mocking of final class & enum. But still getting same error:
Mockito cannot mock/spy because : - final class
Can someone help? Is it really supported in Mockito version 2?
Yes Mockito has supported mocking of final and enum classes. They’ve supported it since version 2.1.0: Mockito - mockito-core 4.6.1 javadoc
Also, the latest version of Mockito is 4.6.1, so I would encourage you to update your libraries if you have the ability to do so.
Thanks. I didn’t know that I have to activate the settings separately. Followed these steps with Mockito 2.1.0 & it worked.