Class TestConstructorUtils
- java.lang.Object
- org.springframework.test.context.support.TestConstructorUtils
public abstract class TestConstructorUtils extends Object
Utility methods for working with@TestConstructor
.Primarily intended for use within the framework.
- Since:
- 5.2
- Author:
- Sam Brannen
- See Also:
TestConstructor
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass)
Determine if the supplied constructor for the given test class is autowirable.static boolean
isAutowirableConstructor(Executable executable, Class<?> testClass)
Determine if the supplied executable for the given test class is an autowirable constructor.
Method Detail
isAutowirableConstructor
public static boolean isAutowirableConstructor(Executable executable, Class<?> testClass)
Determine if the supplied executable for the given test class is an autowirable constructor.This method delegates to
isAutowirableConstructor(Constructor, Class)
if the executable is a constructor.- Parameters:
executable
- an executable for the test classtestClass
- the test class- Returns:
true
if the executable is an autowirable constructor- See Also:
isAutowirableConstructor(Constructor, Class)
isAutowirableConstructor
public static boolean isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass)
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
. @TestConstructor
is present or meta-present on the test class withautowireMode
set toALL
.- The default test constructor autowire mode has been changed to
ALL
(seeTestConstructor.TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME
).
- Parameters:
constructor
- a constructor for the test classtestClass
- the test class- Returns:
true
if the constructor is autowirable- See Also:
isAutowirableConstructor(Executable, Class)
- The constructor is annotated with