Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ runs Kotlin tests annotated with @Ignore

I have a Kotlin project that uses JUnit 5.2.0. When I use IntelliJ to run tests, it runs all tests, even those annotated with @org.junit.Ignore.

package my.package

import org.junit.Ignore
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

class ExampleTests {

    @Test fun runMe() {
        assertEquals(1, 1)
    }

    @Test @Ignore fun dontRunMe() {
        assertEquals(1, 0)
    }
}

IntelliJ Test Runner

Can anyone explain to me why this might be happening?

like image 371
Adenverd Avatar asked Nov 29 '22 21:11

Adenverd


2 Answers

In JUnit 5 you need to use @Disabled annotation for that purpose.

like image 110
amseager Avatar answered Dec 04 '22 00:12

amseager


Figured out the answer: JUnit5 replaces JUnit4's @Ignore with @Disabled.

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test

class ExampleTests {

    @Test fun runMe() {
        assertEquals(1, 1)
    }

    @Test @Disabled fun dontRunMe() {
        assertEquals(1, 0)
    }
}

IDEA test runner

like image 31
Adenverd Avatar answered Dec 04 '22 01:12

Adenverd