我已经为IntelliJ (2020.3)安装了Kotest插件(1.1.22-IC-2020.3)。它允许我为我的Kotlin类创建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)
测试类被编译,jar kotest-core-jvm-4.1.1.jar
被包含为外部库。
有人能在这方面给点建议吗?
发布于 2020-12-18 23:35:28
根据docs的说法,你需要4.2或更高版本,而你使用的是4.1.1。我建议你使用4.3.2。
要使用intellij插件,您需要将kotest-framework-engine-jvm
依赖项添加到构建中。如果您也在使用gradle支持(例如CI或在命令行运行),并且您已经添加了kotest-runner-junit5-jvm
,那么这将传递地引入所需的依赖项。
https://stackoverflow.com/questions/65349223
复制相似问题