How to run Jacoco for Android using Gradle? -


i trying run jacoco gradle sample android app. know both android , java plugin cannot included, believe pre-instrumentation should done android code, before running tests generate jacoco.exec file. however, getting targetinvocationexception, caused java.lang.stackoverflowerror while running gradle build file. error is: fatal error in native method: processing of -javaagent failed

here build.gradle:

buildscript {     repositories {         mavencentral()     }      dependencies {         classpath 'com.android.tools.build:gradle:0.8.+'     } } apply plugin: 'android' apply plugin: 'jacoco'  android {     compilesdkversion 19     buildtoolsversion "19.0.1"      sourcesets {         main {             manifest.srcfile 'androidmanifest.xml'             res.srcdirs = ['res']             java.srcdir file('src')         }     } }      sourcesets {         unittest {             java.srcdir file('unittest/src')         }     }      configurations {         unittestcompile.extendsfrom runtime         unittestruntime.extendsfrom unittestcompile         codecoverage     }      repositories {         mavencentral()     }      dependencies {         unittestcompile files("$project.builddir/classes/release")         unittestcompile 'junit:junit:4.11'         unittestcompile 'org.robolectric:robolectric:2.2'         unittestcompile 'com.google.android:android:4.0.1.2'         codecoverage 'org.jacoco:org.jacoco.agent:0.6.5.201403032054:runtime@jar'     }      tasks.whentaskadded { task ->         if(task.name == 'unittest'){             task.jvmargs "-javaagent:${configurations.codecoverage.aspath}=destfile=${project.builddir.path}/coverage-results/jacoco.exec,sessionid=hsserv,append=false",                     '-djacoco=true',                     '-xms128m',                     '-xmx512m',                     '-xx:maxpermsize=128m'         }      }     task unittest(type:test, dependson: assemble){         description = "run unit tests"         testclassesdir = project.sourcesets.unittest.output.classesdir         classpath = project.sourcesets.unittest.runtimeclasspath          aftertest { desc, result ->             println "executing test ${desc.name} [${desc.classname}] result: ${result.resulttype}"         }     }  build.dependson unittest 

what's wrong here?

try out new gradle plugin 0.10 supports tests jacoco.

dependencies {     classpath 'com.android.tools.build:gradle:0.10.+' } 

from tools.android.com page:

test code coverage support jacoco. enable in tested build type testcoverageenabled = true. html , xml report generated in build/reports/coverage. configure version of jacoco with:

android {   jacoco {     version = '0.6.2.201302030002'   } } 

known issue: not compatible using dagger.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -