Skip to content

Commit ac96ae3

Browse files
author
AimanYosofi
committed
add jcoco testing configurations
1 parent 6f5d4d7 commit ac96ae3

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

build.gradle.kts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
kotlin("jvm") version "1.9.23"
3+
jacoco
34
}
45

56
group = "com.usc.team"
@@ -34,7 +35,69 @@ dependencies {
3435

3536
tasks.test {
3637
useJUnitPlatform()
38+
testLogging {
39+
showStandardStreams = true
40+
}
41+
finalizedBy(tasks.jacocoTestReport)
3742
}
43+
44+
tasks.jacocoTestReport {
45+
dependsOn(tasks.test)
46+
reports {
47+
xml.required.set(true)
48+
csv.required.set(true)
49+
html.required.set(true) // Added HTML report
50+
}
51+
doLast {
52+
println("Coverage report: file://${layout.buildDirectory}/reports/jacoco/test/html/index.html") // Adds clickable report link after test
53+
}
54+
}
55+
56+
tasks.jacocoTestCoverageVerification {
57+
dependsOn(tasks.test)
58+
violationRules {
59+
classDirectories.setFrom(
60+
classDirectories.files.map {
61+
fileTree(it) {
62+
exclude("**/models/**")
63+
exclude("**/di/**")
64+
}
65+
}
66+
)
67+
68+
rule {
69+
limit {
70+
minimum = "0.8".toBigDecimal()
71+
}
72+
}
73+
rule {
74+
limit {
75+
counter = "LINE"
76+
value = "COVEREDRATIO"
77+
minimum = "0.8".toBigDecimal()
78+
}
79+
}
80+
rule {
81+
limit {
82+
counter = "BRANCH"
83+
value = "COVEREDRATIO"
84+
minimum = "0.8".toBigDecimal()
85+
}
86+
}
87+
rule {
88+
limit {
89+
counter = "METHOD"
90+
value = "COVEREDRATIO"
91+
minimum = "0.8".toBigDecimal()
92+
}
93+
}
94+
}
95+
}
96+
97+
jacoco {
98+
toolVersion = "0.8.13"
99+
}
100+
38101
kotlin {
39102
jvmToolchain(17)
40103
}

0 commit comments

Comments
 (0)