I have a Kotlin project and when I run my JUnit tests, I can\'t see tests execution result in IntelliJ and get this message instead:
test events were not
your most likey not tellinig the system how to run the tests.
on your class header define a test runner like this for example:
@RunWith(MockitoJUnitRunner::class)
class MYTest {//...}
or can define junitX runner , etc
For me, the Same issue was occurring, below changes worked for me.
IntelliJ Version I am using: 2019.2.2
In IntelliJ IDE, Go to
File -> Settings ->Build,Execution, Deployment -> Build Tools -> Gradle
here in the Run test using:
dropdown selected option was: Gradle(default)
changed it to IntelliJ IDEA
For those who still might have this problem using IntelliJ & Kotlin:
Add the following lines to the build.grade.kts. I hope it helps some of you.
dependencies {
testImplementation(kotlin("test-junit5"))
testImplementation(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter")}
tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
PS: without adding the "task." before test{...} I was getting the following error!
the function invoke() is not found
Answer
I know of some issues that occur when running Gradle together with the newest JDK versions (13 & 14). If you selected either version 13 or 14 of the JVM as the Gradle JVM try using either 8 or 11.
Switch the Gradle JVM to version 11:
File -> Settings -> Build Execution, etc -> Built Tools -> Gradle -> Gradle JVM
Explanation
I believe that by default Intellij will use the project SDK:
Project strcuture -> Project -> Project SDK
I've had this on several occasions now and picking version 11 of the JVM fixed things for me.
Worth noting is that for most of my project I'm using:
I don't remember where I read it but I believe there were some issues with the lombok plugin + gradle + JVM version. I might revisit this answer if I can remember where I found the post about it.
I often have to delete build and out folder to fix this problem ..
For a Spring boot, gradle project using IntelliJ, my issue was that Spring Boot currently brings JUnit 5 with it. I had also manually installed JUnit 5 as well.
After deleting compile 'org.junit.jupiter:junit-jupiter-api:5.6.3'
in build.gradle
my tests began to work again.