Gradle在Kotlin和JUnit 5中找不到我的测试

我已经用Kotlin和Junit 5写了一些基本的unit testing。不幸的是,当我从Intellij IDEA运行它们时,Gradle没有find这些测试。 我收到来自Gradle的消息“没有find给定的测试包括:[de.mhaug.phd.btcwallet.BasicTests]”和来自Intellij的消息“未收到测试事件”。

有趣的是,使用“./gradlew:clean:test”从命令行运行它报告一个成功的构建。 不过,我的第一个测试显然是红色的,所以这表明Gradle没有执行它。

我已经尝试运行它更详细的输出,但没有任何帮助出现。 这是一个最小的(不)工作的例子:

package de.mhaug.phd.btcwallet import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Test class BasicTests { @Test fun hey() { assertEquals(3,1+1) } @Test fun hey2() { assertFalse(3==1+1) } } 

这是我的build.gradle:

 buildscript { ext.kotlin_version = '1.2.10' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } group 'de.mhaug.phd' version '1.0-SNAPSHOT' apply plugin: 'kotlin' repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.0.2' testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.0.2' // testCompile group: 'org.junit.platform', name: 'junit-platform-runner', version: '' // testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.0.2' } compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } 

我如何使Intellij / Gradle执行我的测试?