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 SummaryModifier and TypeMethodDescriptionstatic booleanisAutowirableConstructor(Constructor<?> constructor, Class<?> testClass) Determine if the supplied constructor for the given test class is autowirable.static booleanisAutowirableConstructor(Constructor<?> constructor, Class<?> testClass, PropertyProvider fallbackPropertyProvider) Determine if the supplied constructor for the given test class is autowirable.static booleanisAutowirableConstructor(Executable executable, Class<?> testClass) Determine if the supplied executable for the given test class is an autowirable constructor.static booleanisAutowirableConstructor(Executable executable, Class<?> testClass, PropertyProvider fallbackPropertyProvider) Determine if the supplied executable for the given test class is an autowirable constructor.
- 
Method Details- 
isAutowirableConstructorDetermine if the supplied executable for the given test class is an autowirable constructor.This method delegates to isAutowirableConstructor(Executable, Class, PropertyProvider)will a value ofnullfor the fallbackPropertyProvider.- Parameters:
- executable- an executable for the test class
- testClass- the test class
- Returns:
- trueif the executable is an autowirable constructor
- See Also:
 
- 
isAutowirableConstructorDetermine if the supplied constructor for the given test class is autowirable.This method delegates to isAutowirableConstructor(Constructor, Class, PropertyProvider)will a value ofnullfor the fallbackPropertyProvider.- Parameters:
- constructor- a constructor for the test class
- testClass- the test class
- Returns:
- trueif the constructor is autowirable
- See Also:
 
- 
isAutowirableConstructorpublic static boolean isAutowirableConstructor(Executable executable, Class<?> testClass, @Nullable PropertyProvider fallbackPropertyProvider) Determine if the supplied executable for the given test class is an autowirable constructor.This method delegates to isAutowirableConstructor(Constructor, Class, PropertyProvider)if the supplied executable is a constructor and otherwise returnsfalse.- Parameters:
- executable- an executable for the test class
- testClass- the test class
- fallbackPropertyProvider- fallback property provider used to look up the value for- TestConstructor.TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAMEif no such value is found in- SpringProperties
- Returns:
- trueif the executable is an autowirable constructor
- Since:
- 5.3
- See Also:
 
- 
isAutowirableConstructorpublic static boolean isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass, @Nullable PropertyProvider fallbackPropertyProvider) Determine if the supplied constructor for the given test class is autowirable.A constructor is considered to be autowirable if one of the following conditions is true.- The constructor is annotated with @Autowired,@jakarta.inject.Inject, or@javax.inject.Inject.
- @TestConstructoris present or meta-present on the test class with- autowireModeset to- ALL.
- The default test constructor autowire mode has been set to
 ALLinSpringPropertiesor in the supplied fallbackPropertyProvider(seeTestConstructor.TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME).
 - Parameters:
- constructor- a constructor for the test class
- testClass- the test class
- fallbackPropertyProvider- fallback property provider used to look up the value for the default test constructor autowire mode if no such value is found in- SpringProperties
- Returns:
- trueif the constructor is autowirable
- Since:
- 5.3
 
- The constructor is annotated with 
 
-