-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing-conventions.gradle.kts
70 lines (64 loc) · 1.63 KB
/
testing-conventions.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
plugins {
id("dependency-management")
jacoco
}
dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.mockk:mockk-jvm:1.13.10")
testImplementation("com.ninja-squad:springmockk:4.0.2")
testImplementation("io.kotest:kotest-assertions-core-jvm:5.8.1")
}
tasks.test {
useJUnitPlatform()
// generate report after tests run
finalizedBy(tasks.jacocoTestReport)
}
tasks.check {
// coverage is part of check
finalizedBy(tasks.jacocoTestCoverageVerification)
}
val excluded = setOf(
"**/entity/**",
"**/exception/**",
"**/**Config**",
)
tasks.jacocoTestReport {
// tests are required to run before generating the report
dependsOn(tasks.test)
// require xml report
reports {
xml.required.set(true)
}
// exclude excluded packages from test report
classDirectories.setFrom(
files(
classDirectories.files.map {
fileTree(it) {
exclude(excluded)
}
}
)
)
}
tasks.jacocoTestCoverageVerification {
// tests are required to run before generating the coverage verification
dependsOn(tasks.test)
// set required coverage to 100%
violationRules {
rule {
limit {
minimum = BigDecimal("1.00")
}
}
}
// exclude excluded packages from test coverage verification
classDirectories.setFrom(
files(
classDirectories.files.map {
fileTree(it) {
exclude(excluded)
}
}
)
)
}