将Spek 2与Gradle Kotlin DSL一起使用时存在一些问题。当我右键单击我的测试文件夹并单击run all tests
时,出现此错误:WARNING: TestEngine with ID 'spek2' failed to discover tests
。我是否在错误地构建脚本?这在子项目中。
//subproject build.gradle.kts
plugins {
kotlin("jvm")
java
}
dependencies {
testImplementation(kotlin("reflect", Vof.kotlin))
testImplementation(kotlin("test", Vof.kotlin))
testImplementation(group = "org.spekframework.spek2", name = "spek-dsl-jvm", version = Vof.spek) {
exclude(group = "org.jetbrains.kotlin")
}
testRuntimeOnly(group = "org.spekframework.spek2", name = "spek-runner-junit5", version = Vof.spek) {
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.junit.platform")
}
testRuntimeOnly("org.junit.platform:junit-platform-launcher:${Vof.junitPlatform}")
testImplementation(gradleTestKit())
}
tasks {
named<Test>("test") {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
我也使用了教程中的格式进行了尝试:
tasks {
test {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
,但是具有相同的错误。 Spek由于某种原因无法找到测试。有什么想法吗?
编辑:这是完整的堆栈跟踪
Feb 24, 2019 9:41:07 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'spek2' failed to discover tests
java.lang.IllegalStateException: clz.java.`package` must not be null
at org.spekframework.spek2.runtime.scope.PathBuilder$Companion.from(Path.kt:86)
at org.spekframework.spek2.runtime.SpekRuntime.discover(SpekJvmRuntime.kt:30)
at org.spekframework.spek2.junit.SpekTestEngine.discover(SpekTestEngine.kt:76)
at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:177)
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:164)
at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:120)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:52)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)