spring-framework / org.springframework.test.context.junit.jupiter

Package org.springframework.test.context.junit.jupiter

Types

SpringExtension

open class SpringExtension : BeforeAllCallback, AfterAllCallback, TestInstancePostProcessor, BeforeEachCallback, AfterEachCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, ParameterResolver

SpringExtension integrates the Spring TestContext Framework into JUnit 5's Jupiter programming model.

To use this extension, simply annotate a JUnit Jupiter based test class with @ExtendWith(SpringExtension.class), @SpringJUnitConfig, or @SpringJUnitWebConfig.

Annotations

DisabledIf

class 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 {} 

EnabledIf

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 {} 

SpringJUnitConfig

class SpringJUnitConfig

@SpringJUnitConfig is a composed annotation that combines ExtendWith from JUnit Jupiter with ContextConfiguration from the Spring TestContext Framework.