Skip to content

Commit

Permalink
test: enable Kotest project level config with project listener 🧪
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Jun 1, 2024
1 parent cbedad2 commit 58efc10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package io.foldright.test_utils

import io.foldright.cffu.CffuFactory
import io.kotest.core.annotation.AutoScan
import io.kotest.core.config.AbstractProjectConfig
import io.kotest.core.listeners.AfterProjectListener
import io.kotest.core.listeners.BeforeProjectListener
import io.kotest.matchers.booleans.shouldBeFalse
Expand Down Expand Up @@ -98,22 +98,17 @@ val testForkJoinPoolExecutor: ExecutorService =
createThreadPool("CompletableFutureUseTest_ForkJoinPool", true)

/**
* Introduction to Extensions of kotest
* https://kotest.io/docs/framework/extensions/extensions-introduction.html
*
* To run an extension for every spec in the entire project:
* mark the listener with @AutoScan
* https://kotest.io/docs/framework/project-config.html
*/
@AutoScan
object InitTestThreadPoolsProjectListener : BeforeProjectListener, AfterProjectListener {
object CffuKotestProjectConfig : AbstractProjectConfig(), BeforeProjectListener, AfterProjectListener {
override suspend fun beforeProject() {
println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
println("Env Infos:")
println("Parallelism of ForkJoinPool: ${ForkJoinPool.getCommonPoolParallelism()}")
println("Available Processors of Runtime: ${Runtime.getRuntime().availableProcessors()}")
println("Java Home: ${System.getProperty("java.home")}")
println("Java Version: ${System.getProperty("java.version")}")
println("CI env var: ${System.getenv("CI")} (${isCiEnv()})")
println("CI env var: ${System.getenv("CI")} (is ci env: ${isCiEnv()})")
println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

warmupExecutorService(testThreadPoolExecutor, testForkJoinPoolExecutor)
Expand Down
2 changes: 2 additions & 0 deletions cffu-core/src/test/resources/kotest.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# https://kotest.io/docs/intellij/intellij-properties.html
kotest.framework.classpath.scanning.config.disable=true
kotest.framework.classpath.scanning.autoscan.disable=true
# https://kotest.io/docs/framework/project-config.html#runtime-detection
kotest.framework.config.fqn=io.foldright.test_utils.CffuKotestProjectConfig

0 comments on commit 58efc10

Please sign in to comment.