From 041cdb11ed5889becbfaa08b00a7b247bb9700b2 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 5 May 2015 12:29:26 -0700 Subject: [PATCH] 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. --- all/build.gradle | 15 +++++++++++++++ build.gradle | 1 + 2 files changed, 16 insertions(+) diff --git a/all/build.gradle b/all/build.gradle index 62d648a847..b84a6bcb75 100644 --- a/all/build.gradle +++ b/all/build.gradle @@ -41,3 +41,18 @@ javadoc { options.links subproject.javadoc.options.links.toArray(new String[0]) } } + +task jacocoMerge(type: JacocoMerge) { + destinationFile = file("${buildDir}/jacoco/test.exec") + executionData = files(rootProject.subprojects.jacocoTestReport.executionData) + .minus(files("${buildDir}/jacoco/test.exec")) + .filter { f -> f.exists() } +} + +jacocoTestReport { + dependsOn(jacocoMerge) + + additionalSourceDirs = files(rootProject.subprojects.sourceSets.main.allSource.srcDirs) + sourceDirectories = files(rootProject.subprojects.sourceSets.main.allSource.srcDirs) + classDirectories = files(rootProject.subprojects.sourceSets.main.output) +} diff --git a/build.gradle b/build.gradle index 546d3c2b60..b1b5fdb091 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,7 @@ subprojects { apply plugin: "idea" apply plugin: "osdetector" apply plugin: "signing" + apply plugin: "jacoco" group = "io.grpc" version = "0.1.0-SNAPSHOT"