qdrzwd / dexmaker

Automatically exported from code.google.com/p/dexmaker
0 stars 0 forks source link

Get AbstractMethodError when attempting to run mockito unit tests on android #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
0. Create a new android AVD for 2.3.3 and new android project with a test 
project
1. Add the mockito nightly build and dexmaker's jars to test project's libs 
directory
2. Write a unit test that tries to mock an object
3. Crash!

What is the expected output? What do you see instead?
Expected it to work. Got the following stack trace instead. 
I/TestRunner(  445): ----- begin exception -----
I/TestRunner(  445): 
I/TestRunner(  445): java.lang.AbstractMethodError: abstract method not 
implemented
I/TestRunner(  445):    at 
com.google.dexmaker.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java)
I/TestRunner(  445):    at 
org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
I/TestRunner(  445):    at 
org.mockito.internal.MockitoCore.mock(MockitoCore.java:49)
I/TestRunner(  445):    at org.mockito.Mockito.mock(Mockito.java:1245)
I/TestRunner(  445):    at org.mockito.Mockito.mock(Mockito.java:1139)
I/TestRunner(  445):    at my test method
I/TestRunner(  445):    at java.lang.reflect.Method.invokeNative(Native Method)
I/TestRunner(  445):    at java.lang.reflect.Method.invoke(Method.java:507)
I/TestRunner(  445):    at junit.framework.TestCase.runTest(TestCase.java:154)
I/TestRunner(  445):    at junit.framework.TestCase.runBare(TestCase.java:127)
I/TestRunner(  445):    at 
junit.framework.TestResult$1.protect(TestResult.java:106)
I/TestRunner(  445):    at 
junit.framework.TestResult.runProtected(TestResult.java:124)
I/TestRunner(  445):    at junit.framework.TestResult.run(TestResult.java:109)
I/TestRunner(  445):    at junit.framework.TestCase.run(TestCase.java:118)
I/TestRunner(  445):    at 
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
I/TestRunner(  445):    at 
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
I/TestRunner(  445):    at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
9)
I/TestRunner(  445):    at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
I/TestRunner(  445): ----- end exception -----

What version of the product are you using? On what operating system?
android 2.3. I used the 3-5-2012 dexmaker build and 
mockito-all-1.9.1-snapshot.jar. I'm using eclipse as my dev environment. 

Below is the unit test that fails

public class ATest extends AndroidTestCase {

    public void testMock(){
        mock(ArrayList.class);
    }

}

Original issue reported on code.google.com by MhaleK...@gmail.com on 11 May 2012 at 8:04

GoogleCodeExporter commented 8 years ago
The version of dexmaker is not inline with the new mockito interface and that 
is the reason for the error. If you compile latest mockito and run it against 
dexmaker, you ll see the dependency issue. I ve updated dexmaker somewhere but 
have not uploaded it anywhere. I might do so if the main branch does not get 
updated

Original comment by c...@novoda.com on 11 May 2012 at 8:58

GoogleCodeExporter commented 8 years ago
In the mean time I'm using the jars from your sample project that you posted in 
the mockito issue 308. Seems to work so far....

Original comment by MhaleK...@gmail.com on 11 May 2012 at 9:03

GoogleCodeExporter commented 8 years ago
I have not tried it as I don't have an emulator/device close by but you could 
try:
http://code.google.com/r/carl-dexmaker

it compiles against latest mockito. I ll try to mock on device tomorrow

Original comment by c...@novoda.com on 11 May 2012 at 9:30

GoogleCodeExporter commented 8 years ago
@MhaleKane Exactly the Mockito MockMaker API was changed a bit, we wanted a 
proper API. So the dexmaker implementation is not yet up to date.

@Jesse I think you can update the dexmaker implementation, as the big API 
refactorings are now in good shape. And almost finally ready for release.

Original comment by brice.du...@gmail.com on 14 May 2012 at 9:34

GoogleCodeExporter commented 8 years ago
I need to update dexmaker to work with some recent mockito changes. I'll have a 
fix that right away!

Original comment by jessewil...@google.com on 14 May 2012 at 1:58

GoogleCodeExporter commented 8 years ago
Thanks!

Original comment by MhaleK...@gmail.com on 14 May 2012 at 6:12

GoogleCodeExporter commented 8 years ago
Thanks!

Original comment by MhaleK...@gmail.com on 14 May 2012 at 6:12

GoogleCodeExporter commented 8 years ago
Thanks for the report. Grabbing the latest dexmaker from source or the 
downloads page should address the problem.

Original comment by jessewil...@google.com on 15 May 2012 at 2:11