Skip to content

Commit 3f76378

Browse files
added a gradle test summary
1 parent 71d2920 commit 3f76378

File tree

1 file changed

+47
-23
lines changed

1 file changed

+47
-23
lines changed

build.gradle.kts

+47-23
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins {
1818
checkstyle
1919
jacoco
2020
id("com.rameshkp.openapi-merger-gradle-plugin") version "1.0.4"
21-
id ("org.eclipse.dataspaceconnector.dependency-rules") apply(false)
21+
id("org.eclipse.dataspaceconnector.dependency-rules") apply (false)
2222
id("com.autonomousapps.dependency-analysis") version "1.0.0-rc05" apply (false)
2323
}
2424

@@ -189,29 +189,53 @@ allprojects {
189189
showStackTraces = true
190190
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
191191
}
192+
193+
// this is the kotlin equivalent of a Groovy's "afterSuite" Closure to
194+
// print a quick test summary.
195+
// inspirations taken from https://stackoverflow.com/a/36130467/7079724 and
196+
// https://github.com/gradle/kotlin-dsl-samples/issues/836#issuecomment-384206237
197+
addTestListener(object : TestListener {
198+
override fun beforeSuite(suite: TestDescriptor) {}
199+
override fun beforeTest(testDescriptor: TestDescriptor) {}
200+
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
201+
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
202+
if (suite.parent == null) { // will match the outermost suite
203+
val output =
204+
"Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
205+
val startItem = "| ";
206+
val endItem = " |";
207+
val repeatLength = startItem.length + output.length + endItem.length
208+
println(
209+
'\n' + ("-".repeat(repeatLength)) + "\n" + startItem + output + endItem + "\n" + ("-".repeat(
210+
repeatLength
211+
))
212+
)
213+
}
214+
}
215+
})
192216
}
217+
}
193218

194-
tasks.withType<Checkstyle> {
195-
reports {
196-
// lets not generate any reports because that is done from within the Github Actions workflow
197-
html.required.set(false)
198-
xml.required.set(false)
199-
}
219+
tasks.withType<Checkstyle> {
220+
reports {
221+
// lets not generate any reports because that is done from within the Github Actions workflow
222+
html.required.set(false)
223+
xml.required.set(false)
200224
}
225+
}
201226

202-
tasks.jar {
203-
metaInf {
204-
from("${rootProject.projectDir.path}/LICENSE")
205-
from("${rootProject.projectDir.path}/NOTICE.md")
206-
}
227+
tasks.jar {
228+
metaInf {
229+
from("${rootProject.projectDir.path}/LICENSE")
230+
from("${rootProject.projectDir.path}/NOTICE.md")
207231
}
232+
}
208233

209-
// Generate XML reports for Codecov
210-
if (System.getenv("JACOCO") == "true") {
211-
tasks.jacocoTestReport {
212-
reports {
213-
xml.required.set(true)
214-
}
234+
// Generate XML reports for Codecov
235+
if (System.getenv("JACOCO") == "true") {
236+
tasks.jacocoTestReport {
237+
reports {
238+
xml.required.set(true)
215239
}
216240
}
217241
}
@@ -247,13 +271,13 @@ if (project.hasProperty("dependency.analysis")) {
247271
}
248272
apply(plugin = "com.autonomousapps.dependency-analysis")
249273
configure<com.autonomousapps.DependencyAnalysisExtension> {
250-
// See https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin
274+
// See https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin
251275
issues {
252276
all { // all projects
253277
onAny {
254278
severity(project.property("dependency.analysis").toString())
255279
exclude(
256-
// dependencies declared at the root level for all modules
280+
// dependencies declared at the root level for all modules
257281
"org.jetbrains:annotations",
258282
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310",
259283
"com.fasterxml.jackson.core:jackson-core",
@@ -263,7 +287,7 @@ if (project.hasProperty("dependency.analysis")) {
263287
}
264288
onUnusedDependencies {
265289
exclude(
266-
// dependencies declared at the root level for all modules
290+
// dependencies declared at the root level for all modules
267291
"com.github.javafaker:javafaker",
268292
"org.assertj:assertj-core",
269293
"org.junit.jupiter:junit-jupiter-api",
@@ -273,7 +297,7 @@ if (project.hasProperty("dependency.analysis")) {
273297
}
274298
onIncorrectConfiguration {
275299
exclude(
276-
// some common dependencies are intentionally exported by core:base for simplicity
300+
// some common dependencies are intentionally exported by core:base for simplicity
277301
"com.squareup.okhttp3:okhttp",
278302
"net.jodah:failsafe",
279303
)
@@ -286,7 +310,7 @@ if (project.hasProperty("dependency.analysis")) {
286310
abi {
287311
exclusions {
288312
excludeAnnotations(
289-
"io\\.opentelemetry\\.extension\\.annotations\\.WithSpan",
313+
"io\\.opentelemetry\\.extension\\.annotations\\.WithSpan",
290314
)
291315
}
292316
}

0 commit comments

Comments
 (0)