forked from codeniko/JsonPathKt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests_codecov.gradle
158 lines (134 loc) · 4.17 KB
/
tests_codecov.gradle
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
ext {
readmeFormat = false // pass -DreadmeFormat to format benchmark results to update readme
kotestVersion = '4.1.0.RC2'
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
testApi 'com.jayway.jsonpath:json-path:2.4.0'
testImplementation "org.json:json:20180813"
testImplementation "io.kotest:kotest-runner-junit5-jvm:$kotestVersion" // for kotest framework
testImplementation "io.kotest:kotest-assertions-core-jvm:$kotestVersion" // for kotest core jvm assertions
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
task benchmark(type: Test) {
// enable junit 5
useJUnitPlatform()
doFirst {
if (!System.getProperty("readmeFormat", "false").equals("false")) {
readmeFormat = true
}
if (readmeFormat) {
jvmArgs '-DreadmeFormat=true'
readmeFormat = false
}
filter {
include("com/nfeld/jsonpathkt/BenchmarkTest.class")
}
testLogging {
showStandardStreams = true
}
}
// Make this task never up to date, thus forcing rerun of all tests whenever task is run
outputs.upToDateWhen { false }
}
task perfTest(type: Test) {
// enable junit 5
useJUnitPlatform()
doFirst {
filter {
include("com/nfeld/jsonpathkt/PerfTest.class")
}
testLogging {
// show test results for following events
events 'PASSED', 'FAILED', 'SKIPPED'
// show printlines
showStandardStreams = true
}
}
// Make this task never up to date, thus forcing rerun of all tests whenever task is run
outputs.upToDateWhen { false }
}
test {
// enable junit 5
useJUnitPlatform()
doFirst {
filter {
includeTestsMatching("com.nfeld.jsonpathkt.*")
exclude(
"com/nfeld/jsonpathkt/BenchmarkTest.class",
"com/nfeld/jsonpathkt/PerfTest.class"
)
}
testLogging {
// show test results for following events
events 'PASSED', 'FAILED', 'SKIPPED'
// show printlines
showStandardStreams = true
}
// show test summary at end
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
}
}
}
// Make this task never up to date, thus forcing rerun of all tests whenever task is run
outputs.upToDateWhen { false }
// code coverage
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/junitPlatformTest.exec")
includeNoLocationClasses = true
}
finalizedBy jacocoTestReport
}
jacoco {
toolVersion = "0.8.5"
reportsDir = file("$buildDir/reports")
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage report."
classDirectories = fileTree(
dir: "$buildDir/classes/kotlin/main"
)
def coverageSourceDirs = [
"src/main/kotlin"
]
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files("$buildDir/jacoco/junitPlatformTest.exec")
reports {
xml.enabled = true
html.enabled = true
csv.enabled = false
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
// Exclude simple LinkedHashMap subclass from report
fileTree(dir: it, excludes: [
'**/LRUCache$LRUMap*',
'**/JsonNodeKt*'
])
})
}
}
check.dependsOn jacocoTestCoverageVerification
jacocoTestCoverageVerification {
violationRules {
rule {
// element = 'CLASS'
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.90
}
}
}
}