'How to re-run failed JUnit5 tests immediately?

I would like to automatically replay my JUnit 5 tests when they fail.

With JUnit 4, I was using Rule with public class Retry implements TestRule like here: How to Re-run failed JUnit tests immediately?

This solution worked for me, it applied to all tests without having to put an annotation on each test. And on the test reports only the last test instance was kept.

Is there an equivalent on JUnit5?

I tried with the @RepeatedIfExceptionsTest(repeats = 2) annotation, but it has to be put on every test. And for test reports it's not ideal, it looks like there are more tests. You should only keep the last instance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source