Skip to content

Commit

Permalink
Exclude generated Protobuf messages from coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea committed Jul 9, 2020
1 parent 4024af5 commit 4db9e12
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 47 deletions.
49 changes: 2 additions & 47 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ plugins {
id('idea')
}

apply from: 'jacoco.gradle'

group = "tech.relaycorp"

repositories {
Expand Down Expand Up @@ -63,53 +65,6 @@ sourceSets {
}
}

jacoco {
toolVersion = "0.8.5"
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
html.destination = file("$buildDir/reports/coverage")
}
}

jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
maximum = "0".toBigDecimal()
}
limit {
counter = "METHOD"
value = "MISSEDCOUNT"
maximum = "0".toBigDecimal()
}

limit {
counter = "BRANCH"
value = "MISSEDCOUNT"
maximum = "0".toBigDecimal()
}
}
}
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
finalizedBy("jacocoTestReport")
doLast {
println("View code coverage at:")
println("file://$buildDir/reports/coverage/index.html")
}
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions.jvmTarget = "1.8"
}
Expand Down
63 changes: 63 additions & 0 deletions jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
jacoco {
toolVersion = "0.8.5"
}

def jacocoFiles = files([
fileTree(
dir: project.buildDir,
includes: ["generated/source/proto/main/java/"],
excludes: [
'**/tech.relaycorp.poweb.internal.protobuf_messages.handshake/**'
]
)
])

jacocoTestReport {
classDirectories.from = jacocoFiles

reports {
xml.enabled = true
html.enabled = true
html.destination = file("$buildDir/reports/coverage")
}
}

jacocoTestCoverageVerification {
afterEvaluate {
classDirectories.from = jacocoFiles
}

violationRules {
rule {
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
maximum = "0".toBigDecimal()
}

limit {
counter = "METHOD"
value = "MISSEDCOUNT"
maximum = "0".toBigDecimal()
}

limit {
counter = "BRANCH"
value = "MISSEDCOUNT"
maximum = "0".toBigDecimal()
}
}
}
}

test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
finalizedBy("jacocoTestReport")
doLast {
println("View code coverage at:")
println("file://$buildDir/reports/coverage/index.html")
}
}

0 comments on commit 4db9e12

Please sign in to comment.