1

I would like to have an assertion in the @AfterAll method after aggregating data from a @ParameterizedTest. Unfortunately, it doesn't work because the exceptions thrown within the @AfterAll method are not propagated up.

class ExampleTest {

    @AfterAll
    static void afterAll() {
        throw new RuntimeException("will not fail the test");
    }
}

Is there any way to have an assertion after all test methods have completed?

Edit: it appears to be a problem with Intellij. I reported it as a bug.

armandino
  • 17,625
  • 17
  • 69
  • 81
  • Did you try to make it non-static with annotation on class `@TestInstance(TestInstance.Lifecycle.PER_CLASS)`? – Alex Apr 23 '22 at 07:17
  • It is not a good idea to make assertion in `@AfterAll` IMO. This is used for teardown such as closing resource, connection, etc. – Kai-Sheng Yang Apr 23 '22 at 07:25

0 Answers0