-
@Retention(RUNTIME) @Target(TYPE) @Inherited @ExtendWith(DisableIfTestFailsExtension.class) public @interface DisableIfTestFails
Disables all remaining tests in a container if one of them failed.By default, all exceptions (including assertions, but exempting failed assumptions) will lead to disabling the remaining tests. To configure this in more detail, see
with()andonAssertion().This annotation can be (meta-)present on classes that contain a nested class. In that case, a failing test in the outer class will disable the nested class (if it runs later) and vice versa.
This annotation can be (meta-)present on a class and/or its super types (classes or interfaces). In that case, the exception types given to
with()are merged andonAssertion()is or'ed.But if a test fails in a specific class, only other tests in the corresponding container will be disabled. That means if...
- a class
SpecificTestsimplements interfaceTestsand Testsis annotated with@DisableIfTestFailsand- a test in
SpecificTestsfails
SpecificTestsare disabled and other implementations ofTestsremain unaffected, i.e. their tests are not disabled. - a class
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanonAssertionSet tofalseif failed assertions should not lead to disabling remaining tests.java.lang.Class<? extends java.lang.Throwable>[]withConfigure on which exceptions remaining tests are disabled (defaults to "any exception").
-
-
-
Element Detail
-
with
java.lang.Class<? extends java.lang.Throwable>[] with
Configure on which exceptions remaining tests are disabled (defaults to "any exception").If
@DisableIfTestFailsis present multiple times (e.g. on multiple super types), these exceptions are collected across all annotations, meaning if any of the mentioned exceptions are thrown, the remaining tests are disabled.- Default:
- {}
-
-
-
onAssertion
boolean onAssertion
Set tofalseif failed assertions should not lead to disabling remaining tests.If
@DisableIfTestFailsis present multiple times (e.g. on multiple super types), this value is or'ed, meaning as soon as one annotation says to fail on assertion errors, that's how the container will behave.- Default:
- true
-
-