spring-framework / org.springframework.test.context.junit.jupiter / EnabledIf / <init>

<init>

EnabledIf(value: String, expression: String, reason: String, loadContext: Boolean)

@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