Skip to content

Commit 9663a95

Browse files
authored
Jvm project config (#69)
* Add ProjectConfig to kotest-jvm This gives a concrete example of how/where to add and configure ProjectConfig in JVM projects. The added config adds a test execution timer line to the `./gradlew kotest` output. * Update README.md
1 parent 4d3e888 commit 9663a95

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

kotest-jvm/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# kotest-jvm
22

33
Example project showing how to use Kotest for JVM projects.
4+
5+
This also has a `ProjectConfig` example that adds a line
6+
for every test output that shows the time it took to run
7+
that test when executing `./gradlew kotest --rerun`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.kotest.provided
2+
3+
import io.kotest.core.config.AbstractProjectConfig
4+
import io.kotest.core.listeners.AfterTestListener
5+
import io.kotest.core.test.TestCase
6+
import io.kotest.engine.test.TestResult
7+
8+
object TimerListener : AfterTestListener {
9+
override suspend fun afterAny(testCase: TestCase, result: TestResult) =
10+
println("- ${testCase.name.name} ${result.duration}")
11+
}
12+
13+
object ProjectConfig : AbstractProjectConfig() {
14+
override val extensions = listOf(TimerListener)
15+
}

0 commit comments

Comments
 (0)