I have written some basic unit tests with Kotlin and Junit 5. Unfortunately, when I run them from Intellij IDEA, the tests are not found by Gradle. I am getting the message "No tests found for given includes: [de.mhaug.phd.btcwallet.BasicTests]" from Gradle and the message "Test event not received" from Intellij.
Interestingly, running it from the commandline with "./gradlew :clean :test" reports a successful build. However, my first test is obviously red, so this shows that Gradle did not execute it.
I already tried running it with more verbose output but nothing helpful showed up. Here is a minimal (not) working example:
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)
}
}
This is my 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"
}
How can I make Intellij/Gradle execute my tests?