3.4. JUnit 4 @Ignore Support
In order to provide a smooth migration path from JUnit 4 to JUnit Jupiter, the junit-jupiter-migrationsupport
module provides support for JUnit 4’s @Ignore
annotation analogous to Jupiter’s [@Disabled](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/Disabled.html)
annotation.
To use @Ignore
with JUnit Jupiter based tests, configure a test dependency on the junit-jupiter-migrationsupport
module in your build and then annotate your test class with @ExtendWith(IgnoreCondition.class)
or [@EnableJUnit4MigrationSupport](https://junit.org/junit5/docs/current/api/org.junit.jupiter.migrationsupport/org/junit/jupiter/migrationsupport/EnableJUnit4MigrationSupport.html)
(which automatically registers the IgnoreCondition
along with Limited JUnit 4 Rule Support). The IgnoreCondition
is an [ExecutionCondition](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/extension/ExecutionCondition.html)
that disables test classes or test methods that are annotated with @Ignore
.
import org.junit.Ignore;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.migrationsupport.EnableJUnit4MigrationSupport;
// @ExtendWith(IgnoreCondition.class)
@EnableJUnit4MigrationSupport
class IgnoredTestsDemo {
@Ignore
@Test
void testWillBeIgnored() {
}
@Test
void testWillBeExecuted() {
}
}
JUnit 4 @Ignore support in JUnit Jupiter is currently an experimental feature. Consult the table in Experimental APIs for detail. |