Skip to content

Skip failed tests #3435

Answered by sormuras
mwisnicki asked this question in Q&A
Aug 24, 2023 · 3 comments · 2 replies
Discussion options

You must be logged in to vote

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:

  @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)
       …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@mwisnicki
Comment options

@mwisnicki
Comment options

Answer selected by mwisnicki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3432 on August 25, 2023 07:32.