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(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
-
isAutowirableConstructor
Determine 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 classtestClass- the test class- Returns:
trueif the executable is an autowirable constructor- See Also:
-
isAutowirableConstructor
Determine 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 classtestClass- the test class- Returns:
trueif the constructor is autowirable- See Also:
-
isAutowirableConstructor
public 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 classtestClass- the test classfallbackPropertyProvider- fallback property provider used to look up the value forTestConstructor.TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAMEif no such value is found inSpringProperties- Returns:
trueif the executable is an autowirable constructor- Since:
- 5.3
- See Also:
-
isAutowirableConstructor
public 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 withautowireModeset toALL.- 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 classtestClass- the test classfallbackPropertyProvider- fallback property provider used to look up the value for the default test constructor autowire mode if no such value is found inSpringProperties- Returns:
trueif the constructor is autowirable- Since:
- 5.3
- The constructor is annotated with
-