“Test events were not received” when run tests using Intellij

前端 未结 13 2267
花落未央
花落未央 2021-02-06 21:11

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

相关标签:
13条回答
  • 2021-02-06 21:41

    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

    0 讨论(0)
  • 2021-02-06 21:42

    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

    0 讨论(0)
  • 2021-02-06 21:44

    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

    0 讨论(0)
  • 2021-02-06 21:48

    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:

    • Lombok
    • Jackson
    • Lombok plugin (Require annotation processing to be enabled)

    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.

    0 讨论(0)
  • 2021-02-06 21:50

    I often have to delete build and out folder to fix this problem ..

    0 讨论(0)
  • 2021-02-06 21:50

    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.

    0 讨论(0)
提交回复
热议问题