Adenverd
Adenverd

Reputation: 488

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?

Upvotes: 7

Views: 11295

Answers (2)

Adenverd
Adenverd

Reputation: 488

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

Upvotes: 13

amseager
amseager

Reputation: 6391

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

Upvotes: 20

Related Questions