-
I would like to be able to mark certain failed tests as skipped/ignored. Currently it is only possible to skip/ignore tests before they are run. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It should work using a custom
If everything else doesn't work, you may always resort to a try-catch in your test method and "handle" appropriate exception calling |
Beta Was this translation helpful? Give feedback.
-
That will report test as successful. I'm trying to report test as failed or at least skipped. |
Beta Was this translation helpful? Give feedback.
-
Here are two examples showing an instance of @Test
void f() {
try {
throw new RuntimeException("might happen");
} catch (RuntimeException exception) {
Assumptions.abort("f");
}
}
@Test
@ExtendWith(AbortOnRuntimeException.class)
void g() {
throw new RuntimeException("might happen");
}
public static class AbortOnRuntimeException implements TestExecutionExceptionHandler {
@Override
public void handleTestExecutionException(ExtensionContext context, Throwable throwable)
throws Throwable {
if (throwable instanceof RuntimeException exception) {
Assumptions.abort(exception.getMessage());
}
throw throwable;
}
} |
Beta Was this translation helpful? Give feedback.
Here are two examples showing an instance of
RuntimeException
, that would trigger a test to be marked as failed, being transformed into an aborted test - which in turn is interpreted (by IDEA) as skipped tests: