Skip to content

Commit 041cdb1

Browse files
committed
Add Jacoco code coverage
After running tests, you can run jacocoTestReport. The jacocoTestReport task does not depend on the tests, so they should be run separately. There is still a lot of noise in the jacoco output since we aren't yet filtering generated code.
1 parent cde7eaa commit 041cdb1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

all/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,18 @@ javadoc {
4141
options.links subproject.javadoc.options.links.toArray(new String[0])
4242
}
4343
}
44+
45+
task jacocoMerge(type: JacocoMerge) {
46+
destinationFile = file("${buildDir}/jacoco/test.exec")
47+
executionData = files(rootProject.subprojects.jacocoTestReport.executionData)
48+
.minus(files("${buildDir}/jacoco/test.exec"))
49+
.filter { f -> f.exists() }
50+
}
51+
52+
jacocoTestReport {
53+
dependsOn(jacocoMerge)
54+
55+
additionalSourceDirs = files(rootProject.subprojects.sourceSets.main.allSource.srcDirs)
56+
sourceDirectories = files(rootProject.subprojects.sourceSets.main.allSource.srcDirs)
57+
classDirectories = files(rootProject.subprojects.sourceSets.main.output)
58+
}

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ subprojects {
1515
apply plugin: "idea"
1616
apply plugin: "osdetector"
1717
apply plugin: "signing"
18+
apply plugin: "jacoco"
1819

1920
group = "io.grpc"
2021
version = "0.1.0-SNAPSHOT"

0 commit comments

Comments
 (0)