Jacoco HTML reports display correct results but jacoco.exec shows 0% coverage

126 views
Skip to first unread message

sahana...@gmail.com

unread,
Mar 4, 2016, 7:28:08 PM3/4/16
to JaCoCo and EclEmma Users
I am using the following script for jacoco code coverage. HTML reports display correct results, where as the exec files show 0% coverage. I am using JUnit testing, and my Unit tests are located at app/src/test/. I am trying to use this jacoco.exec in jenkins to display my results. My jenkins is setup using amtrix project plugin. What am I doing wrong?

apply plugin: 'jacoco'

jacoco {
toolVersion = "0.7.5.201505241946"
}

project.afterEvaluate {
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type -> type.name }
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }

// When no product flavors defined, use empty
if (!productFlavors) productFlavors.add('')

productFlavors.each { productFlavorName ->
buildTypes.each { buildTypeName ->
def sourceName, sourcePath
if (!productFlavorName) {
sourceName = sourcePath = "${buildTypeName}"
} else {
sourceName = "${productFlavorName}${buildTypeName.capitalize()}"
sourcePath = "${productFlavorName}/${buildTypeName}"
}
def testTaskName = "test${sourceName.capitalize()}UnitTest"

// Create coverage task of form 'testFlavorTypeCoverage' depending on 'testFlavorTypeUnitTest'
task "${testTaskName}Coverage" (type:JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports on the ${sourceName.capitalize()} build."

classDirectories = fileTree(
dir: "${project.buildDir}/intermediates/classes/${sourcePath}",
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)

def coverageSourceDirs = [
"src/main/java",
"src/$productFlavorName/java",
"src/$buildTypeName/java"
]
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec")

reports {
xml.enabled = true
html.enabled = true
html.destination = "${System.getenv('View_Root')}/_Build/Jacoco"
}
}
}
}
}

Marc R. Hoffmann

unread,
Mar 7, 2016, 2:20:27 PM3/7/16
to jac...@googlegroups.com
Hi,

the Jenkins plugin is a separate project. Please see documentation what
is included by the JaCoCo project:

http://eclemma.org/jacoco/trunk/doc/integrations.html

You'll find the links to the other projects maintaining the respective
integrations.

Regards,
-marc
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages