在 Gradle Kotlin DSL 中使用 Spek 2 时遇到了一些问题。当我右键单击我的测试文件夹并点击时,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)