I want to spy the Linkedlist in android.
List list = new LinkedList();
List spyData = Mockito.spy(list);
spyData.add("xxxx");
However, the exception occured.
java.lang.AbstractMethodError: abstract method "boolean org.mockito.internal.invocation.AbstractAwareMethod.isAbstract()"
at org.mockito.internal.invocation.InvocationImpl.callRealMethod(InvocationImpl.java:109)
at org.mockito.internal.stubbing.answers.CallsRealMethods.answer(CallsRealMethods.java:41)
at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:93)
at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:29)
at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:38)
at com.google.dexmaker.mockito.InvocationHandlerAdapter.invoke(InvocationHandlerAdapter.java:49)
at LinkedList_Proxy.add(LinkedList_Proxy.generated)
at com.app.test.testmethod(mytest.java:202)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1858)
The dependencies of libs are
dexmaker-1.2.jar
dexmaker-mockito-1.2.jar
mockito-core-1.10.19.jar
Even I update mockito-core-1.10.19.jar
to mockito-core-2.0.31-beta.jar
,
the problem still exists.
But Mockito.mock(Linkedlist.class)
is ok, I have no ideas about this problem.
Thank you.
I just found another way to solve the problem.
This is an issue for dexmaker 1.2, we should upgrade to dexmaker 1.4, dexmaker-mockito 1.4 and include dexmaker-dx-1.4.
So the dependencies are
dexmaker-dx-1.4.jar
dexmaker-1.4.jar
dexmaker-mockito-1.4.jar
mockito-core-1.10.19.jar