Reputation: 5737
This error happens when I try and run my Android Instrumentation tests on a new 4.4 device, when they have always worked in the past
[echo] Running tests...
[echo] Running tests ...
[exec] INSTRUMENTATION_RESULT: shortMsg=java.lang.NoClassDefFoundError
[exec] INSTRUMENTATION_RESULT: longMsg=java.lang.NoClassDefFoundError: org.mockito.internal.runners.RunnerImpl
[exec] INSTRUMENTATION_CODE: 0
Upvotes: 3
Views: 2634
Reputation: 5737
I posted that question to help others avoid wasting time stupidly like I have done!
The problem was that when I upgraded my Nexus 4 to Android 4.4 Kitkat, I decided to play around by activating the new Android RunTime (ART) in the Developer's Options settings menu.
That is the result!
To run your instrumentation tests, switch back to Dalvik!
I'm using Mockito, Dexmaker and Dexmaker-Mockito all to run Instrumentation tests with Mockito and use Emma to get coverage data.
No doubt some updating or change of approach will be needed in the future to test on Dalvik and/or ART.
Upvotes: 10
Reputation: 3065
Using "*" like @tmuget suggested, doesn't work from the command line, but as suggested but the Japanese blog post, it looks like setting any specification on tests to run works around the NoClassDefFound issue. If you package is com.$somthing you can use:
adb shell am instrument -w -r -e debug false -e package com
Some related issues to watch:
Upvotes: 1
Reputation: 1165
I found a workaround when running ART: use the option -e package *
of the testrunner.
This will correctly run all your tests, and it works with Mockito, Dexmaker and Dexmaker-Mockito.
Here's an example when running via Ant:
<run-tests-helper emma.enabled="true">
<extra-instrument-args>
<arg value="-e" />
<arg value="coverageFile" />
<arg value="${emma.dump.file}" />
<arg value="-e" />
<arg value="package" />
<arg value="*" />
</extra-instrument-args>
</run-tests-helper>
Upvotes: 0