From 58efc10764c5df453a6fa6fdc75db09355dd792d Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sat, 25 May 2024 20:20:45 +0800 Subject: [PATCH] =?UTF-8?q?test:=20enable=20`Kotest`=20project=20level=20c?= =?UTF-8?q?onfig=20with=20project=20listener=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foldright/test_utils/TestThreadPoolManager.kt | 13 ++++--------- cffu-core/src/test/resources/kotest.properties | 2 ++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cffu-core/src/test/java/io/foldright/test_utils/TestThreadPoolManager.kt b/cffu-core/src/test/java/io/foldright/test_utils/TestThreadPoolManager.kt index af3eb632..a2d0a5b2 100644 --- a/cffu-core/src/test/java/io/foldright/test_utils/TestThreadPoolManager.kt +++ b/cffu-core/src/test/java/io/foldright/test_utils/TestThreadPoolManager.kt @@ -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 @@ -98,14 +98,9 @@ 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:") @@ -113,7 +108,7 @@ object InitTestThreadPoolsProjectListener : BeforeProjectListener, AfterProjectL 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) diff --git a/cffu-core/src/test/resources/kotest.properties b/cffu-core/src/test/resources/kotest.properties index 296c06a9..fcf0167b 100644 --- a/cffu-core/src/test/resources/kotest.properties +++ b/cffu-core/src/test/resources/kotest.properties @@ -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