Class TestConstructorUtils
java.lang.Object
org.springframework.test.context.support.TestConstructorUtils
Utility methods for working with
@TestConstructor.
Primarily intended for use within the framework.
- Since:
- 5.2
- Author:
- Sam Brannen, Florian Lehmann
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAutowirableConstructor(Executable executable, @Nullable PropertyProvider fallbackPropertyProvider) Determine if the suppliedExecutableis an autowirableConstructor.
-
Method Details
-
isAutowirableConstructor
public static boolean isAutowirableConstructor(Executable executable, @Nullable PropertyProvider fallbackPropertyProvider) Determine if the suppliedExecutableis an autowirableConstructor.A constructor is considered to be autowirable if one of the following conditions is
true.- The constructor is annotated with
@Autowiredor@jakarta.inject.Inject. @TestConstructoris present or meta-present on the test class withautowireModeset toALL.- The default test constructor autowire mode has been set to
ALLinSpringPropertiesor in the supplied fallbackPropertyProvider.
- Parameters:
executable- anExecutablefor a test classfallbackPropertyProvider- fallback property provider used to look up the value for "spring.test.constructor.autowire.mode" if no such value is found inSpringProperties; may benullif there is no fallback support- Returns:
trueif the executable is an autowirable constructor- Since:
- 6.2.13
- See Also:
- The constructor is annotated with
-