I've exhausted a variety of search terms I thought would net me a direct answer, and I have found nothing definitive (even in JUnit5's docs). Is there a way to retrieve the "reason" from a @Disabled annotation in JUnit5? Current approach I am working with:
instanceof Disabled
The logic is there and works on a single specific test run, but when I run a full test class the method is skipped over in the BeforeEachCallback's @Override. So I assume JUnit does some magic that excludes it from the test run lifecycle as a whole. If that is the case, is there a way to retrieve that annotation and log it at an earlier point than BeforeEachCallback? I've also tried BeforeAllCallback, but wasn't able to access the method children of the test class.
Extension APIs such as BeforeEachCallback
are not invoked for a test method that is disabled via an ExecutionCondition
.
JUnit Jupiter 5.4 introduced a new TestWatcher
extension API that has a testDisabled()
callback for disabled tests. You can find out more about it in the User Guide.