@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) @ExtendWith(EnabledIfCondition) class EnabledIf
@EnabledIf is used to signal that the annotated test class or test method is enabled and should be executed if the supplied #expression evaluates to true.
When applied at the class level, all test methods within that class are automatically enabled by default 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 @EnabledOnMac annotation can be created as follows.
@Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @EnabledIf( expression = "#{systemProperties['os.name'].toLowerCase().contains('mac')}", reason = "Enabled on Mac OS" ) public @interface EnabledOnMac {}
Author
Sam Brannen
Since
5.0
See Also
SpringExtensionDisabledIforg.junit.jupiter.api.Disabled
EnabledIf(value: String, expression: String, reason: String, loadContext: Boolean)
When applied at the class level, all test methods within that class are automatically enabled by default as well. For basic examples, see the Javadoc for This annotation may be used as a meta-annotation to create custom composed annotations. For example, a custom
|
val expression: String
The expression that will be evaluated to determine if the annotated test class or test method is enabled. If the expression evaluates to Expressions can be any of the following.
Note, however, that a text literal which is not the result of dynamic resolution of a property placeholder is of zero practical value since |
|
val loadContext: Boolean
Whether the Defaults to |
|
val reason: String
The reason this test is enabled. |
|
val value: String
Alias for |