I have a project which consists of two modules: serverlib and testserver:
- serverlib
- src/main/java <-- also tested by testserver
- testserver
- src/main/java
- src/test/java <-- integrationtests
serverlib contains classes which are used by testserver and are tested by the integration tests for testserver. I’ve setup integration tests according to the documentation in the gretty plugin. This all works but Jacoco only shows the coverage of the code for testserver
How can I include coverage for serverlib in the Jacoco report generated when running the integration test for testserver ?
Relevant parts of my build.gradle:
dependencies {
compile project(":serverlib") // <-- these classes should also appear in the coverage report
}
task('integrationTest', type: Test) {
include '**/*IT.*'
}
tasks.test {
exclude '**/*IT.*'
}
gretty {
afterEvaluate {
tasks.appBeforeIntegrationTest.jacoco {
append = false
destinationFile = project.file("$project.buildDir/jacoco/integrationTestServer.exec")
}
tasks.appAfterIntegrationTest.finalizedBy tasks.integrationTestServerReport
}
task('integrationTestServerReport', type: JacocoReport) {
executionData { tasks.appBeforeIntegrationTest.jacoco.destinationFile }
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = sourceSets.main.output
def reportDir = reporting.file("jacoco/integrationTest_server/html")
reports {
html.destination = reportDir
}
}