I have a pretty basic build.gradle with a small twist: I’ve separated unit & integration tests into separate tasks, and include
by package. Trouble is, I can’t for the life of me get jacoco to generate a report for either of them, let alone my goal of a combined coverage report. I’ve tried pretty much every way I can think of to configure jacoco & I can’t get it to generate any reports; the only way I’ve succeeded is by using jacoco in the test task. Test source root is src/test/java, and in it are two packages, unit & integration.
How do I get jacoco to produce a combined report to determine code coverage across both unit & integration test code?
Here’s my build.gradle:
plugins {
id 'java-library'
id 'maven'
id 'jacoco'
}
version = "${version}${Boolean.parseBoolean(releaseBuild) ? '' : '-SNAPSHOT'}"
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
deployerJars
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven {
url "https://redacted"
}
}
task unitTest(type: Test) {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
include 'unit/**'
dependsOn compileTestJava
jacoco {
include 'unit/**'
}
}
task integrationTestOnly(type: Test) {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
include 'integration/**'
dependsOn compileTestJava
mustRunAfter unitTest
jacoco {
include 'integration/**'
}
}
task integrationTest(type: Task) {
dependsOn unitTest, integrationTestOnly
}
test {
exclude '**' // exclude all to leave testing to tasks unitTest & integrationTest
dependsOn integrationTest
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:23.0'
testCompile 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
deployerJars "org.apache.maven.wagon:wagon-http-lightweight:3.0.0"
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "https://redacted") {
authentication(userName: System.properties["nexusUser"], password: System.properties["nexusPassword"])
}
snapshotRepository(url: "https://redacted") {
authentication(userName: System.properties["nexusUser"], password: System.properties["nexusPassword"])
}
}
}
Thanks in advance!
-matthew