Unable to exclude a package in android for code coverage

892 views
Skip to first unread message

puvsp...@gmail.com

unread,
Feb 15, 2017, 2:15:23 AM2/15/17
to JaCoCo and EclEmma Users
Hi,

Am new to jacoco and in learning phase.
Am unable to exclude some packages which i don't want it under code coverage.
Using grade only.

Please find my jacoco.gradle file below. Am applying this jacoco.gradle file in build.gradle with apply from: 'jacoco.gradle'

apply plugin: 'jacoco'

jacoco {
toolVersion = "0.7.6.201602180812"
}

android {
testOptions {
unitTests.all {
jacoco {
//includeNoLocationClasses = true
}
}
}
}

project.afterEvaluate {

android.applicationVariants.all { variant ->
def name = variant.name
def testTaskName = "test${name.capitalize()}UnitTest"

tasks.create(name: "${testTaskName}Coverage", type: JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports for the ${name.capitalize()} build."

classDirectories = fileTree(
dir: "${project.buildDir}/intermediates/classes/${name}",
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/ui/**', // -->would like to exclude this package and should not be considered.
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)

sourceDirectories = files(['src/main/java'].plus(android.sourceSets[name].java.srcDirs))
executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec")

reports {
xml.enabled = true
html.enabled = true
}
}
}
}

Tried with the options provided in google, no luck out of it.
Not only the specified package and would like to exclude other packages like interfaces, singleton and private methods too. Request you to please please help me in this regard.

Thanks and Regards,
Satya Prasad.

puvsp...@gmail.com

unread,
Feb 15, 2017, 5:28:48 AM2/15/17
to JaCoCo and EclEmma Users, puvsp...@gmail.com
> If am not going in the right way for exclusion of packages, please suggest how to exclude so that i can get accurate code coverage.

Evgeny Mandrikov

unread,
Feb 15, 2017, 6:29:24 AM2/15/17
to JaCoCo and EclEmma Users, puvsp...@gmail.com
Gradle plugin that integrates JaCoCo is not developed by JaCoCo Team, but by Gradle, so you'd better seek help from Gradle community - they by definition should know more about this integration.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages