类 InfraExtension
- 所有已实现的接口:
org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.AfterTestExecutionCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.BeforeTestExecutionCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.ParameterResolver,org.junit.jupiter.api.extension.TestInstancePostProcessor
ApplicationExtension integrates the TestContext Framework
into JUnit 5's Jupiter programming model.
To use this extension, simply annotate a JUnit Jupiter based test class with
@ExtendWith(ApplicationExtension.class), @ApplicationJUnitConfig, or
@ApplicationJUnitWebConfig.
- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private static final org.junit.jupiter.api.extension.ExtensionContext.NamespaceExtensionContext.Namespacein which@Autowiredvalidation error messages are stored, keyed by test class.private static final cn.taketoday.util.ReflectionUtils.MethodFilterprivate static final List<Class<? extends Annotation>>private static final Stringprivate static final org.junit.jupiter.api.extension.ExtensionContext.NamespaceExtensionContext.Namespacein which@RecordApplicationEventsvalidation error messages are stored, keyed by test class.private static final org.junit.jupiter.api.extension.ExtensionContext.NamespaceExtensionContext.Namespacein whichTestContextManagersare stored, keyed by test class. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context) Delegates toTestContextManager.afterTestClass().voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) voidafterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) Delegates toTestContextManager.beforeTestClass().voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) static cn.taketoday.context.ApplicationContextgetApplicationContext(org.junit.jupiter.api.extension.ExtensionContext context) Get theApplicationContextassociated with the suppliedExtensionContext.private static org.junit.jupiter.api.extension.ExtensionContext.StoregetStore(org.junit.jupiter.api.extension.ExtensionContext context) (专用程序包) static TestContextManagergetTestContextManager(org.junit.jupiter.api.extension.ExtensionContext context) Get theTestContextManagerassociated with the suppliedExtensionContext.private static booleanvoidpostProcessTestInstance(Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context) Delegates toTestContextManager.prepareTestInstance(java.lang.Object).resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Resolve a value for theParameterin the suppliedParameterContextby retrieving the corresponding dependency from the test'sApplicationContext.private booleansupportsApplicationEvents(org.junit.jupiter.api.extension.ParameterContext parameterContext) booleansupportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Determine if the value for theParameterin the suppliedParameterContextshould be autowired from the test'sApplicationContext.private voidvalidateAutowiredConfig(org.junit.jupiter.api.extension.ExtensionContext context) Validate that test methods and test lifecycle methods in the supplied test class are not annotated with@Autowired.private voidvalidateRecordApplicationEventsConfig(org.junit.jupiter.api.extension.ExtensionContext context) Validate that the test class or its enclosing class doesn't attempt to record application events in a parallel mode that makes it non-deterministic (@TestInstance(PER_CLASS)and@Execution(CONCURRENT)combination).
-
字段详细资料
-
TEST_CONTEXT_MANAGER_NAMESPACE
private static final org.junit.jupiter.api.extension.ExtensionContext.Namespace TEST_CONTEXT_MANAGER_NAMESPACEExtensionContext.Namespacein whichTestContextManagersare stored, keyed by test class. -
AUTOWIRED_VALIDATION_NAMESPACE
private static final org.junit.jupiter.api.extension.ExtensionContext.Namespace AUTOWIRED_VALIDATION_NAMESPACEExtensionContext.Namespacein which@Autowiredvalidation error messages are stored, keyed by test class. -
NO_VIOLATIONS_DETECTED
- 另请参阅:
-
RECORD_APPLICATION_EVENTS_VALIDATION_NAMESPACE
private static final org.junit.jupiter.api.extension.ExtensionContext.Namespace RECORD_APPLICATION_EVENTS_VALIDATION_NAMESPACEExtensionContext.Namespacein which@RecordApplicationEventsvalidation error messages are stored, keyed by test class. -
JUPITER_ANNOTATION_TYPES
-
autowiredTestOrLifecycleMethodFilter
private static final cn.taketoday.util.ReflectionUtils.MethodFilter autowiredTestOrLifecycleMethodFilter
-
-
构造器详细资料
-
InfraExtension
public InfraExtension()
-
-
方法详细资料
-
beforeAll
Delegates toTestContextManager.beforeTestClass().- 指定者:
beforeAll在接口中org.junit.jupiter.api.extension.BeforeAllCallback- 抛出:
Exception
-
afterAll
Delegates toTestContextManager.afterTestClass().- 指定者:
afterAll在接口中org.junit.jupiter.api.extension.AfterAllCallback- 抛出:
Exception
-
postProcessTestInstance
public void postProcessTestInstance(Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context) throws Exception Delegates toTestContextManager.prepareTestInstance(java.lang.Object).this method also validates that test methods and test lifecycle methods are not annotated with
@Autowired.- 指定者:
postProcessTestInstance在接口中org.junit.jupiter.api.extension.TestInstancePostProcessor- 抛出:
Exception
-
validateRecordApplicationEventsConfig
private void validateRecordApplicationEventsConfig(org.junit.jupiter.api.extension.ExtensionContext context) Validate that the test class or its enclosing class doesn't attempt to record application events in a parallel mode that makes it non-deterministic (@TestInstance(PER_CLASS)and@Execution(CONCURRENT)combination). -
validateAutowiredConfig
private void validateAutowiredConfig(org.junit.jupiter.api.extension.ExtensionContext context) Validate that test methods and test lifecycle methods in the supplied test class are not annotated with@Autowired. -
beforeEach
- 指定者:
beforeEach在接口中org.junit.jupiter.api.extension.BeforeEachCallback- 抛出:
Exception
-
beforeTestExecution
public void beforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - 指定者:
beforeTestExecution在接口中org.junit.jupiter.api.extension.BeforeTestExecutionCallback- 抛出:
Exception
-
afterTestExecution
public void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception Delegates toTestContextManager.afterTestExecution(java.lang.Object, java.lang.reflect.Method, java.lang.Throwable).- 指定者:
afterTestExecution在接口中org.junit.jupiter.api.extension.AfterTestExecutionCallback- 抛出:
Exception
-
afterEach
Delegates toTestContextManager.afterTestMethod(java.lang.Object, java.lang.reflect.Method, java.lang.Throwable).- 指定者:
afterEach在接口中org.junit.jupiter.api.extension.AfterEachCallback- 抛出:
Exception
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Determine if the value for theParameterin the suppliedParameterContextshould be autowired from the test'sApplicationContext.A parameter is considered to be autowirable if one of the following conditions is
true.- The declaring
executable is a
ConstructorandTestConstructorUtils.isAutowirableConstructor(Constructor, Class, PropertyProvider)returnstrue. Note thatisAutowirableConstructor()will be invoked with a fallbackPropertyProviderthat delegates its lookup toExtensionContext.getConfigurationParameter(String). - The parameter is of type
ApplicationContextor a sub-type thereof. - The parameter is of type
ApplicationEventsor a sub-type thereof. ParameterResolutionDelegate.isAutowirable(java.lang.reflect.Parameter, int)returnstrue.
WARNING: If a test class
Constructoris annotated with@Autowiredor automatically autowirable (seeTestConstructor), Infra will assume the responsibility for resolving all parameters in the constructor. Consequently, no other registeredParameterResolverwill be able to resolve parameters.- 指定者:
supportsParameter在接口中org.junit.jupiter.api.extension.ParameterResolver- 另请参阅:
-
resolveParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)TestConstructorUtils.isAutowirableConstructor(Constructor, Class)ParameterResolutionDelegate.isAutowirable(java.lang.reflect.Parameter, int)
- The declaring
executable is a
-
supportsApplicationEvents
private boolean supportsApplicationEvents(org.junit.jupiter.api.extension.ParameterContext parameterContext) -
resolveParameter
@Nullable public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Resolve a value for theParameterin the suppliedParameterContextby retrieving the corresponding dependency from the test'sApplicationContext.Delegates to
ParameterResolutionDelegate.resolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, cn.taketoday.beans.factory.config.AutowireCapableBeanFactory).- 指定者:
resolveParameter在接口中org.junit.jupiter.api.extension.ParameterResolver- 另请参阅:
-
supportsParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)ParameterResolutionDelegate.resolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, cn.taketoday.beans.factory.config.AutowireCapableBeanFactory)
-
getApplicationContext
public static cn.taketoday.context.ApplicationContext getApplicationContext(org.junit.jupiter.api.extension.ExtensionContext context) Get theApplicationContextassociated with the suppliedExtensionContext.- 参数:
context- the currentExtensionContext(nevernull)- 返回:
- the application context
- 抛出:
IllegalStateException- if an error occurs while retrieving the application context- 另请参阅:
-
getTestContextManager
static TestContextManager getTestContextManager(org.junit.jupiter.api.extension.ExtensionContext context) Get theTestContextManagerassociated with the suppliedExtensionContext.- 返回:
- the
TestContextManager(nevernull)
-
getStore
private static org.junit.jupiter.api.extension.ExtensionContext.Store getStore(org.junit.jupiter.api.extension.ExtensionContext context) -
isAutowiredTestOrLifecycleMethod
-