Jacoco/Java/Gradle with submodules - no integration tests

925 views
Skip to first unread message

kkam...@skillz.com

unread,
Apr 12, 2017, 9:27:16 AM4/12/17
to SonarQube
Hi,

We are not seeing integration test coverage in SQ with Jacoco.  Here's a snippet from our build.gradle


plugins {
id "org.sonarqube" version "2.3"
}

apply plugin: 'org.sonarqube'

allprojects {
apply plugin: 'java'
apply plugin: 'jacoco'

jacoco {
toolVersion = '0.7.9'
}
}
subprojects {
jacocoTestReport
{
    additionalSourceDirs = files(sourceSets.main.allSource.srcDirs)
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = files(sourceSets.main.output)
reports {
html.enabled = true
xml.enabled = false
csv.enabled = false
}
}
...
}
sonarqube {
properties {
property "sonar.projectName", "Java :: Our Project"
property "sonar.projectKey", "project-key"
property "sonar.jacoco.reportPaths", "${project.buildDir}/jacoco/test.exec"
}
}

task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn(subprojects.test)

additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)

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

doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}


We have several subprojects with their own "test.exec" and "integration.exec" files which we have tried adding to reportPaths, but we're seeing the following when we build:

Property 'sonar.jacoco.reportPath' is deprecated. Please use 'sonar.jacoco.reportPaths' instead.
Class not found: com.google.errorprone.annotations.CanIgnoreReturnValue
Class not found: javax.annotation.Nullable

...even though we don't have "reportPath" defined.

Other versions worth noting:
SonarQube 6.3.0.19869
Java 1.8
Gradle 3.3
Tests are Spock/Groovy

Several of us have been combing the internet with no luck, although this feels like a pretty fundamental problem and we're not running with an odd stack.

Any help is appreciated!



kkam...@skillz.com

unread,
Apr 14, 2017, 2:31:31 PM4/14/17
to SonarQube, kkam...@skillz.com
Hi all,

I'm bumping this thread to see if I can get any traction on it :)  

Thanks in advance!

Julien HENRY

unread,
Apr 18, 2017, 11:50:42 AM4/18/17
to SonarQube, kkam...@skillz.com
Hi,

The warning is probably due to the fact that the scanner for Gradle is himself adding the sonar.jacoco.reportPath. You can see effective values by running ./gradlew sonarqube -Dsonar.scanner.dumpToFile=out.txt

I don't see in your configuration where you set the path to the integration test report. Please try to append it to:
property "sonar.jacoco.reportPaths", "${project.buildDir}/jacoco/test.exec"

for example:
property "sonar.jacoco.reportPaths", "${project.buildDir}/jacoco/test.exec,${project.buildDir}/jacoco/integration.exec"

Regards,

Julien

Mirko Friedenhagen

unread,
Apr 18, 2017, 1:22:53 PM4/18/17
to SonarQube
BTW: if I am not mistaken SQ does not differentiate anymore between coverage stemming from unit and integration tests, only the combined coverage is shown (which is a big pity IMO).
Reply all
Reply to author
Forward
0 new messages