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.

  1. import org.junit.Ignore;
  2. import org.junit.jupiter.api.Test;
  3. import org.junit.jupiter.migrationsupport.EnableJUnit4MigrationSupport;
  4. // @ExtendWith(IgnoreCondition.class)
  5. @EnableJUnit4MigrationSupport
  6. class IgnoredTestsDemo {
  7. @Ignore
  8. @Test
  9. void testWillBeIgnored() {
  10. }
  11. @Test
  12. void testWillBeExecuted() {
  13. }
  14. }
JUnit 4 @Ignore support in JUnit Jupiter is currently an experimental feature. Consult the table in Experimental APIs for detail.