I’ve been using JaCoCo via the Gradle plugin and it’s been working well, but I’ve just moved some of my code base into subprojects and I’m no longer getting coverage.
The JaCoCo agent generates the exec file correctly.
The report is also generated and sessions page has the classes from the sub project, but there is no coverage in the main coverage page.
I’ve written an SSCCE for the problem:
├── build.gradle
├── settings.gradle
├── src
│ └── cucumber
│ ├── java
│ │ └── a
│ │ └── Steps.java
│ └── resources
│ └── test.feature
└── sub
└── src
└── main
└── java
└── a
└── Sub.java
build.gradle
plugins {
id 'java'
id 'jacoco'
id 'com.github.samueltbrown.cucumber' version '0.9'
}
repositories {
mavenCentral()
}
cucumber {
glueDirs = ['src/cucumber/java']
featureDirs = ['src/cucumber/resources']
jvmOptions {
def jacocoAgent = zipTree(configurations.jacocoAgent.singleFile).filter { it.name == 'jacocoagent.jar' }.singleFile
def jacocoResult = "$buildDir/results/jacoco/cucumber.exec"
jvmArgs = ["-javaagent:$jacocoAgent=destfile=$jacocoResult,append=false"]
}
}
jacocoTestReport {
executionData = files("$buildDir/results/jacoco/cucumber.exec")
reports {
html.destination "$buildDir/reports/jacoco"
}
}
dependencies {
cucumberCompile 'info.cukes:cucumber-java:1.2.5'
cucumberCompile project('sub')
}
subprojects {
apply plugin: 'java'
}
I’ve tried playing with the properties of the jacocoTestReport task, but nothing seems to help.
I’m running on Arch linux with OpenJDK 8 and Gradle 3.3.
I find JaCoCo indispensable for creating quality software and would greatly appreciate any help.