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)
}
}
Can anyone explain to me why this might be happening?
In JUnit 5 you need to use @Disabled annotation for that purpose.
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)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With