Is there any hook in Junit5 that reacts to fails in @Before* methods?
I use a @BeforeAll method to init environment for my tests. But this initialization may sometimes fail. I want to dump the environment, to find out whats wrong, but I need to do it before @After* methods are called, which will clear the environment and destroy all info.
We're talking about dozens of these @BeforeAll methods across the test suite, so doing it manually inside each method is not an option.
I've already tried these, but no luck:
TestWatcherdoes not work for this, since it only fires if an actual test is executed.TestExecutionListener.executionFinishedlooks promising, but it fires after all the @After methods, which is too late for me.- I even tried to do it inside the @AfterAll cleanup methods, before the actual cleanup. But found no way to detect which tests were executed or if anything failed.
Any ideas?