My android application uses the following config:
- Gradle - 0.12.+
Contents of build.gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'com.android.library'
apply plugin: "jacoco"
dependencies {
compile 'commons-collections:commons-collections:3.2.1'
compile 'org.slf4j:slf4j-android:1.6.1-RC1'
// dependency injection
compile('org.roboguice:roboguice:2.0') {
exclude module: 'cglib'
exclude module: 'aopalliance'
exclude module: 'guice'
}
compile files('libs/guice-3.0-no_aop.jar')
compile 'javax.inject:javax.inject:1'
/*
* Test dependencies.
*/
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
}
android {
buildToolsVersion "20.0"
compileSdkVersion 19
buildTypes {
debug {
runProguard false
testCoverageEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 100
versionName "1.0.0"
}
/*
* Workaround for packaging bug in Android Gradle plugin regarding duplicate files.
*/
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
}
}
All my tests run successfully when property testCoverageEnabled is set to false. On setting it to true, the following exception is thrown when running the tests
Caused by: java.lang.VerifyError: *** Some class ***
at dalvik.system.DexFile.defineClass(Native Method)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211)
at dalvik.system.DexPathList.findClass(DexPathList.java:313)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:51)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
The error happens on the line when mocks are initialised within the tests.
Has anyone managed to generate code coverage metrics for android application which uses mockito library for testing?