0

just wanted to clarify my understanding of the error I get is correct please...

java.lang.ExceptionInInitializerError
at org.mockito.internal.creation.jmock.ClassImposterizer.createProxyClass(ClassImposterizer.java:85)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:62)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:56)
at org.mockito.internal.creation.CglibMockMaker.createMock(CglibMockMaker.java:23)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
at org.mockito.Mockito.mock(Mockito.java:1243)
at org.mockito.Mockito.mock(Mockito.java:1120)
at uk.co.flurrished.test.ResultActivityTest.setUp(ResultActivityTest.java:51)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
Caused by: java.lang.VerifyError: org.mockito.cglib.core.ReflectUtils
at org.mockito.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:167)
at org.mockito.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)

As you can see, this is littered with cglib references, and not a mention of dexedlibs. Is it safe to assume that the dexing isn't happening and Mockito is trying to use CGLib to construct the Reflection bootstrapping. If so, given I have mockito-1.9.5-all and both the dexmaker and dexmaker-mockito in my libs, does anyone know how I can force it to use these dex libs. Stackoverflow and Googlecode is littered with this issue, but nothing works for me yet. TDD on Android seems all but impossible at the moment.

Many thanks

Mike

bric3
  • 40,072
  • 9
  • 91
  • 111
MikeB
  • 577
  • 5
  • 15
  • Also, just compiled Mockito 1.9.8 to see if different, but is same error. – MikeB Jul 23 '13 at 22:53
  • Hum this should work, you definitely should check the classpath when the test is run on Dalvik – bric3 Jul 24 '13 at 11:30
  • Thanks Brice. No luck. Do you know whether I should be seeing cglib in the stacktrace at all or is this normal - I don't know what I'm looking for in terms of clues as to the dexedLibs being loaded? They are in my bin folder, I can see them, and my .classpath lists them – MikeB Jul 24 '13 at 19:42
  • no CGLIB shouldn't appear, if dexmaker is found on the classpath then CGLIB is never used. I'm repeating myself but in my opinion you should definitely double check the actual classpath. – bric3 Jul 25 '13 at 00:48
  • Apologies you are repeating yourself Brice. I don't know how to find the actual classpath used vs the .classpath file content which correctly includes the dexmaker...thanks – MikeB Jul 25 '13 at 09:51
  • No pun intended ;) I'm not an Android developer, but we've worked with the dexmaker guys and we've had many report like yours which were resolved by fixing actual runtime classpath when the test is run. I don't know how to check that, plus it might be a bit different if you use **Eclipse** or **Android Studio** from **Jetbrains**. But this would seem the most logical explanation on why **Mockito** doesn't see the extension **dexmaker-mockito**. – bric3 Jul 25 '13 at 10:00
  • Which Android version are you using? Does running dexdump on your test APK include dexmaker classes? – Jesse Wilson Jul 26 '13 at 22:53
  • Hi Jesse, many thanks - yes, have used dexdump and yes they are there, which is the confusing bit. Device is running 2.3.7, which should be okay right? – MikeB Jul 28 '13 at 18:53
  • ...same on 4.2...given the libraries are on the classpath, loaded and visible in dexdump, why the cglib stream of errors? In the trace, I'm seeing this kind of stuff...07-28 20:37:28.726: I/dalvikvm(18684): Could not find method java.beans.Introspector.getBeanInfo, referenced from method org.mockito.cglib.core.ReflectUtils.getPropertiesHelper .....which again looks like mockito is using JavaBeans on the dalvik vm? – MikeB Jul 28 '13 at 19:34

0 Answers0