Annotation Interface TestConstructor


@Target(TYPE) @Retention(RUNTIME) @Documented @Inherited public @interface TestConstructor
@TestConstructor is a type-level annotation that is used to configure how the parameters of a test class constructor are autowired from components in the test's ApplicationContext.

If @TestConstructor is not present or meta-present on a test class, the default test constructor autowire mode will be used. See TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME for details on how to change the default mode. Note, however, that a local declaration of @Autowired @jakarta.inject.Inject, or @javax.inject.Inject on a constructor takes precedence over both @TestConstructor and the default mode.

This annotation may be used as a meta-annotation to create custom composed annotations.

this annotation is only supported in conjunction with the ApplicationExtension for use with JUnit Jupiter. Note that the ApplicationExtension is often automatically registered for you — for example, when using annotations such as @ApplicationJUnitConfig and @ApplicationJUnitWebConfig or various test-related annotations from Infra Test.

this annotation will be inherited from an enclosing test class by default. See @NestedTestConfiguration for details.

从以下版本开始:
4.0
作者:
Sam Brannen, Harry Yang
另请参阅: