Skip to content

Commit

Permalink
Verify JaCoCo coverage aggregation yields expected results
Browse files Browse the repository at this point in the history
In order to detect breakages in the future, a minimum coverage
percentage rule is now being enforced.
  • Loading branch information
marcphilipp committed Jun 15, 2024
1 parent 45ad2b2 commit 84240c7
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,24 @@ val classesView = configurations["aggregateCodeCoverageReportResults"].incoming.
}
}

tasks.named<JacocoReport>(jacocoRootReport.reportTask.name).configure {
// Override to restore behavior of pre-8.2.1 Gradle (see https://github.com/gradle/gradle/issues/25618)
classDirectories.setFrom(classesView.files)
tasks {
val reportTask = named<JacocoReport>(jacocoRootReport.reportTask.name)
val jacocoRootCoverageVerification by registering(JacocoCoverageVerification::class) {
executionData.from(reportTask.map { it.executionData })
classDirectories.from(reportTask.map { it.classDirectories })
sourceDirectories.from(reportTask.map { it.sourceDirectories })
violationRules {
rule {
limit {
// In order to detect problems with coverage aggregation, we require a minimum coverage percentage
minimum = "0.90".toBigDecimal()
}
}
}
}
reportTask {
// Override to restore behavior of pre-8.2.1 Gradle (see https://github.com/gradle/gradle/issues/25618)
classDirectories.setFrom(classesView.files)
finalizedBy(jacocoRootCoverageVerification)
}
}

0 comments on commit 84240c7

Please sign in to comment.