1

我已经为 IntelliJ (2020.3) 安装了 Kotest 插件 (1.1.22-IC-2020.3)。它允许我为/从我的 Kotlin 类创建 Kotest 测试,但这些测试不能从测试类运行。

kotest 面板显示好像没有测试存在

如果我创建一个新的 Kotest 运行配置,我可以运行测试类,但总是抛出这个异常:

java.lang.NoClassDefFoundError: Could not initialize class io.kotest.core.test.TestResult
    at io.kotest.core.runtime.TestCaseExecutor.executeActiveTest(TestCaseExecutor.kt:127)
    at io.kotest.core.runtime.TestCaseExecutor$intercept$2.invokeSuspend(TestCaseExecutor.kt:75)
    at io.kotest.core.runtime.TestCaseExecutor$intercept$2.invoke(TestCaseExecutor.kt)
    at io.kotest.core.runtime.TestCaseExecutor.executeIfActive(TestCaseExecutor.kt:89)
    at io.kotest.core.runtime.TestCaseExecutor.intercept(TestCaseExecutor.kt:75)
    at io.kotest.core.runtime.TestCaseExecutor.execute(TestCaseExecutor.kt:56)
    at io.kotest.core.engine.SingleInstanceSpecRunner.runTest(SingleInstanceSpecRunner.kt:60)
    at io.kotest.core.engine.SingleInstanceSpecRunner$execute$2$invokeSuspend$$inlined$invoke$lambda$1.invokeSuspend(SingleInstanceSpecRunner.kt:70)
    at io.kotest.core.engine.SingleInstanceSpecRunner$execute$2$invokeSuspend$$inlined$invoke$lambda$1.invoke(SingleInstanceSpecRunner.kt)
    at io.kotest.core.engine.SpecRunner$runParallel$$inlined$map$lambda$1$1.invokeSuspend(SpecRunner.kt:51)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:79)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:54)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at io.kotest.core.engine.SpecRunner$runParallel$$inlined$map$lambda$1.run(SpecRunner.kt:50)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

测试类编译并且 jarkotest-core-jvm-4.1.1.jar作为外部库包含在内。

有人可以对此提供一些建议吗?

4

1 回答 1

2

根据文档,您需要 4.2 或更高版本并且您使用的是 4.1.1。我建议您使用 4.3.2。

要使用 intellij 插件,您需要将kotest-framework-engine-jvm依赖项添加到您的构建中。如果您也在使用 gradle 支持(例如,用于 CI 或在命令行上运行)并且您已添加kotest-runner-junit5-jvm,那么这将引入所需的依赖关系。

于 2020-12-18T15:35:27.900 回答