Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

And the classes that implement these interface will inherit the test cases.

  • Condition test execution.

5 version allows to define custom annotations that act as conditions to determine whether a test should be run or not. It is necessary to create annotation for condition

Code Block
@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(DisabledOnEnvironmentCondition.class)
public @interface DisabledOnEnvironment {
    String[] value();
}

And class that implements the appropriate interface and override the evaluate() method

Code Block
@Override
public ConditionEvaluationResult evaluate(TestExtensionContext context) {
        // evaluation logic
}

Now we can add annotation on the test method

Code Block
@Test
@DisabledOnEnvironment({"dev", "prod"})
void testFail() {
    fail("this test fails");
}


  • Migration Process.

   Migration from JUnit 4 to 5 is not so difficult, as backward compatibility is available.

...