Hello everyone. I have some issues while trying to...
# android
k
Hello everyone. I have some issues while trying to use
Mockito.spy
method on an open class (
open class MenuListModel : LinkedList<MenuItemModel>()
) in my Robolectric test (not sure if it’s relevant). I’m using
org.mockito:mockito-core:2.2.15
and
org.robolectric:robolectric:3.1.4
and I get this when running this test
Copy code
org.mockito.exceptions.base.MockitoException: 
Mockito cannot mock this class: class com.agens.android.vgsnarvei.entities.proxies.MenuListModel.

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.60-b23
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_60-b27
JVM info           : mixed mode
OS name            : Mac OS X
OS version         : 10.11.6


Underlying exception : java.lang.IllegalStateException: Error invoking java.lang.ClassLoader#findClass
and some stacktrace below. I tried to use experimental feature of Mockito 2.0 that allows for mocking final classes, but it didn’t work neither (there’s an issue in Robolectric repo about incompatibility of those two) any idea? Anyone here has an example of working mocking/spying of Kotlin classes with Robolectric?