I've recently tried the new Jacoco code coverage feature for Android Gradle plugin, and unfortunately it makes my tests fail with the following error:
java.lang.VerifyError: com/foo/bar/rest/SomeClass at
com.foo.bar.test.rest.BaseTest.setUp(BaseTest.java:87) at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190) at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175) at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
I enabled the code coverage using these lines in build.gradle:
buildTypes {
debug {
testCoverageEnabled = true
}
...
Has anyone encountered the same problem?
Turning @ben75's comment into an answer: The corresponding bug has been fixed with build-tools 21.0.0. However, that version introduced another Windows-specific bug, so you should use build-tools 21.0.2 instead (even though that version does not yet show up on the revisions page).
I was running into this same problem, but found this solution: add -noverify to your gradle file like so:
testOptions {
unitTests {
all {
// configure the test JVM arguments
jvmArgs '-noverify'
}
}
}
Source: https://github.com/robolectric/robolectric-gradle-plugin/issues/144
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With