类 DependencyInjectionTestExecutionListener
java.lang.Object
cn.taketoday.test.context.support.AbstractTestExecutionListener
cn.taketoday.test.context.support.DependencyInjectionTestExecutionListener
- 所有已实现的接口:
cn.taketoday.core.Ordered,TestExecutionListener
TestExecutionListener which provides support for dependency
injection and initialization of test instances.- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen, Juergen Hoeller, Harry Yang
-
字段概要
字段修饰符和类型字段说明private final AotTestContextInitializersprivate static final cn.taketoday.logging.Loggerstatic final StringAttribute name for aTestContextattribute which indicates whether the dependencies of a test instance should be reinjected inbeforeTestMethod().从接口继承的字段 cn.taketoday.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidbeforeTestMethod(TestContext testContext) If theREINJECT_DEPENDENCIES_ATTRIBUTEin the suppliedtest contexthas a value ofBoolean.TRUE, this method will have the same effect asprepareTestInstance(); otherwise, this method will have no effect.final intgetOrder()Returns2000.protected voidinjectDependencies(TestContext testContext) Performs dependency injection and bean initialization for the suppliedTestContextas described inprepareTestInstance().private voidinjectDependenciesInAotMode(TestContext testContext) voidprepareTestInstance(TestContext testContext) Performs dependency injection on thetest instanceof the suppliedtest contextbyautowiringandinitializingthe test instance via its ownapplication context(without checking dependencies).private booleanrunningInAotMode(Class<?> testClass) Determine if we are running in AOT mode for the supplied test class.从类继承的方法 cn.taketoday.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestExecution, afterTestMethod, beforeTestClass, beforeTestExecution
-
字段详细资料
-
REINJECT_DEPENDENCIES_ATTRIBUTE
Attribute name for aTestContextattribute which indicates whether the dependencies of a test instance should be reinjected inbeforeTestMethod(). Note that dependencies will be injected inprepareTestInstance()in any case.Clients of a
TestContext(e.g., otherTestExecutionListeners) may therefore choose to set this attribute to signal that dependencies should be reinjected between execution of individual test methods.Permissible values include
Boolean.TRUEandBoolean.FALSE. -
logger
private static final cn.taketoday.logging.Logger logger -
aotTestContextInitializers
-
-
构造器详细资料
-
DependencyInjectionTestExecutionListener
public DependencyInjectionTestExecutionListener()
-
-
方法详细资料
-
getOrder
public final int getOrder()Returns2000.- 指定者:
getOrder在接口中cn.taketoday.core.Ordered- 覆盖:
getOrder在类中AbstractTestExecutionListener
-
prepareTestInstance
Performs dependency injection on thetest instanceof the suppliedtest contextbyautowiringandinitializingthe test instance via its ownapplication context(without checking dependencies).The
REINJECT_DEPENDENCIES_ATTRIBUTEwill be subsequently removed from the test context, regardless of its value.- 指定者:
prepareTestInstance在接口中TestExecutionListener- 覆盖:
prepareTestInstance在类中AbstractTestExecutionListener- 参数:
testContext- the test context for the test; nevernull- 抛出:
Exception- allows any exception to propagate
-
beforeTestMethod
If theREINJECT_DEPENDENCIES_ATTRIBUTEin the suppliedtest contexthas a value ofBoolean.TRUE, this method will have the same effect asprepareTestInstance(); otherwise, this method will have no effect.- 指定者:
beforeTestMethod在接口中TestExecutionListener- 覆盖:
beforeTestMethod在类中AbstractTestExecutionListener- 参数:
testContext- the test context in which the test method will be executed; nevernull- 抛出:
Exception- allows any exception to propagate- 另请参阅:
-
injectDependencies
Performs dependency injection and bean initialization for the suppliedTestContextas described inprepareTestInstance().The
REINJECT_DEPENDENCIES_ATTRIBUTEwill be subsequently removed from the test context, regardless of its value.- 参数:
testContext- the test context for which dependency injection should be performed (nevernull)- 抛出:
Exception- allows any exception to propagate- 另请参阅:
-
injectDependenciesInAotMode
- 抛出:
Exception
-
runningInAotMode
Determine if we are running in AOT mode for the supplied test class.
-