Wee have upgraded to Mockito 2 (2.8.9 since it worked fine with PowerMock).
When converting tests we got the following message.
I thought mocking final classes and methods was a new feature in Mockito 2.
The above contradicts it. Or will the message go away when we enable it using:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: interface com.company.mobjects.ObjectHandler.
Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
Java : 1.8
JVM vendor name : Oracle Corporation
JVM vendor version : 25.0-b62
JVM name : Java HotSpot(TM) 64-Bit Server VM
JVM version : 1.8.0-ea-b120
JVM info : mixed mode
OS name : Linux
OS version : 2.6.32-504.el6.x86_64
Underlying exception : java.lang.IllegalArgumentException: object is not an instance of declaring class
at com.company.DotImplTest.setup(DotImplTest.java:31)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at com.company.DotImplTest.setup(DotImplTest.java:31)
We are using an old version of java:
https://stackoverflow.com/questions/37527038/mockito-object-is-not-an-instance-of-declaring-classUse at least jdk 1.8_172