Skip to content

Commit 1fc6573

Browse files
authored
Merge pull request #11 from secure-software-engineering/test_coverage
added jacoco test report
2 parents 7a24299 + f0d794c commit 1fc6573

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

build.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ plugins {
22
kotlin("jvm") version "2.0.0"
33
id("com.diffplug.spotless") version "8.3.0"
44
id("io.gitlab.arturbosch.detekt") version "1.23.8"
5+
java
6+
jacoco
57
}
68

79
group = "fair"
@@ -78,9 +80,29 @@ tasks.register<JavaExec>("debugFair") {
7880

7981
tasks.test {
8082
useJUnitPlatform()
83+
finalizedBy(tasks.jacocoTestReport) // always generate report after tests
8184
maxHeapSize = "4g"
8285
}
8386

87+
tasks.jacocoTestReport {
88+
dependsOn(tasks.test) // ensure tests run first
89+
90+
reports {
91+
xml.required.set(true) // for CI tools
92+
html.required.set(true) // this is the index.html you want
93+
csv.required.set(false)
94+
}
95+
}
96+
97+
tasks.register("testCoverage") {
98+
group = "verification"
99+
description = "Runs tests and generates JaCoCo coverage report"
100+
dependsOn("test", "jacocoTestReport")
101+
doLast {
102+
println("Check the reports in build/reports/jacoco/test/html/index.html")
103+
}
104+
}
105+
84106
tasks.register<Test>("debug") {
85107
group = "verification"
86108
description = "Run tests and generate IntelliJ debug configs for failing assertions"

0 commit comments

Comments
 (0)