I have a unit test, written with JUnit 5 (Jupiter), that is failing. I do not currently have time to fix the problem, so I would like to mark the test as an expected failure. Is there a way to do that?
I see @Disable
which causes the test to not be run. I would like the test to still run (and ideally fail the build if it starts to work), so that I remember that the test is there.
Is there such an annotation in Junit 5? I could use assertThrows
to catch the error, but I would like the build output to indicate that this is not a totally normal test.
You can disable the failing test with the @Disabled
annotation. You can then add another test that asserts the first one does indeed fail:
@Test
@Disabled
void fixMe() {
Assertions.fail();
}
@Test
void fixMeShouldFail() {
assertThrows(AssertionError.class, this::fixMe);
}