@Target(value={TYPE,METHOD}) @Retention(value=RUNTIME) @Documented @ExtendWith(value=DisabledIfCondition.class) public @interface DisabledIf
@DisabledIf
is used to signal that the annotated test class or test
method is disabled and should not be executed if the supplied
expression()
evaluates to true
.
When applied at the class level, all test methods within that class are automatically disabled as well.
For basic examples, see the Javadoc for expression()
.
This annotation may be used as a meta-annotation to create
custom composed annotations. For example, a custom
@DisabledOnMac
annotation can be created as follows.
@Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @DisabledIf( expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}", reason = "Disabled on Mac OS" ) public @interface DisabledOnMac {}
SpringExtension
,
EnabledIf
,
Disabled
Modifier and Type | Optional Element and Description |
---|---|
String |
expression
The expression that will be evaluated to determine if the annotated test
class or test method is disabled.
|
String |
reason
The reason this test is disabled.
|
String |
value
Alias for
expression() ; only intended to be used if an
explicit reason() is not provided. |
@AliasFor(value="expression") public abstract String value
expression()
; only intended to be used if an
explicit reason()
is not provided.expression()
@AliasFor(value="value") public abstract String expression
If the expression evaluates to Boolean.TRUE
or a String
equal to "true"
(ignoring case), the test will be disabled.
Expressions can be any of the following.
@DisabledIf("#{systemProperties['os.name'].toLowerCase().contains('mac')}")
Environment
— for example:
@DisabledIf("${smoke.tests.enabled}")
@DisabledIf("true")
Note, however, that a text literal which is not the result of
dynamic resolution of a property placeholder is of zero practical value
since @DisabledIf("true")
is equivalent to @Disabled
and @DisabledIf("false")
is logically meaningless.
public abstract String reason
expression()