Gradle找不到测试

我正在为我的Kotlin项目使用Spek测试框架。 我能够通过Intellij Idea Spek插件运行测试,但不能通过gradle(构建或测试)运行它们。 根据SimpleTest.kt从Idea插件1运行测试成功和1失败,当通过gradle运行它说1容器找到0测试。 如何设置通过gradle启动测试?

我的gradle和测试文件:

的build.gradle:

buildscript { ext.kotlin_version = '1.1.4-2' repositories { mavenCentral() jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4" } } apply plugin: "idea" apply plugin: "java" apply plugin: "kotlin" apply plugin: "application" apply plugin: "org.junit.platform.gradle.plugin" junitPlatform { filters { engines { include 'spek' } } } mainClassName = "app.MainKt" repositories { mavenCentral() jcenter() maven { url "http://dl.bintray.com/jetbrains/spek" } } dependencies { testCompile 'org.jetbrains.kotlin:kotlin-test' testCompile 'org.jetbrains.spek:spek-api:1.1.2' testCompile 'org.junit.platform:junit-platform-runner:1.0.0-M4' testRuntime 'org.jetbrains.spek:spek-junit-platform-engine:1.1.2' } sourceSets.test.java.srcDirs += 'src/test/kotlin' 

的src /测试/科特林/ SimpleTest.kt:

 import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.dsl.given import org.jetbrains.spek.api.dsl.it import kotlin.test.assertEquals class SimpleTest : Spek({ given("simple test") { it("should succeed") { assertEquals(1, 1) } it("shouldn't succeed") { assertEquals(0, 1) } } }) 

Gradle测试输出:

 Executing external task 'test'... Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0 :generateBuildConfig UP-TO-DATE :compileBuildConfig UP-TO-DATE :extractIncludeProto UP-TO-DATE :extractProto UP-TO-DATE :generateProto UP-TO-DATE :compileKotlin UP-TO-DATE :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :compileTestKotlin Using kotlin incremental compilation :extractIncludeTestProto UP-TO-DATE :extractTestProto UP-TO-DATE :generateTestProto NO-SOURCE :compileTestJava NO-SOURCE :processTestResources NO-SOURCE :testClasses UP-TO-DATE :junitPlatformTest Test run finished after 5062 ms [ 1 containers found ] [ 0 containers skipped ] [ 1 containers started ] [ 0 containers aborted ] [ 1 containers successful ] [ 0 containers failed ] [ 0 tests found ] [ 0 tests skipped ] [ 0 tests started ] [ 0 tests aborted ] [ 0 tests successful ] [ 0 tests failed ] :test :test SKIPPED BUILD SUCCESSFUL in 14s 12 actionable tasks: 2 executed, 10 up-to-date External task execution finished 'test'. 

这是由于Spek 1.1.2和Kotlin 1.1.4之间的兼容性问题导致的https://github.com/JetBrains/spek/issues/248

这可以通过使用Spek 1.1.4和junit-platform 1.0.0-RC2来解决