类 InfraExtension

java.lang.Object
cn.taketoday.test.context.junit.jupiter.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

public class InfraExtension extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.TestInstancePostProcessor, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.ParameterResolver
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
另请参阅:
  • 字段详细资料

    • TEST_CONTEXT_MANAGER_NAMESPACE

      private static final org.junit.jupiter.api.extension.ExtensionContext.Namespace TEST_CONTEXT_MANAGER_NAMESPACE
      ExtensionContext.Namespace in which TestContextManagers are stored, keyed by test class.
    • AUTOWIRED_VALIDATION_NAMESPACE

      private static final org.junit.jupiter.api.extension.ExtensionContext.Namespace AUTOWIRED_VALIDATION_NAMESPACE
      ExtensionContext.Namespace in which @Autowired validation error messages are stored, keyed by test class.
    • NO_VIOLATIONS_DETECTED

      private static final String NO_VIOLATIONS_DETECTED
      另请参阅:
    • RECORD_APPLICATION_EVENTS_VALIDATION_NAMESPACE

      private static final org.junit.jupiter.api.extension.ExtensionContext.Namespace RECORD_APPLICATION_EVENTS_VALIDATION_NAMESPACE
      ExtensionContext.Namespace in which @RecordApplicationEvents validation error messages are stored, keyed by test class.
    • JUPITER_ANNOTATION_TYPES

      private static final List<Class<? extends Annotation>> JUPITER_ANNOTATION_TYPES
    • autowiredTestOrLifecycleMethodFilter

      private static final cn.taketoday.util.ReflectionUtils.MethodFilter autowiredTestOrLifecycleMethodFilter
  • 构造器详细资料

    • InfraExtension

      public InfraExtension()
  • 方法详细资料

    • beforeAll

      public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      指定者:
      beforeAll 在接口中 org.junit.jupiter.api.extension.BeforeAllCallback
      抛出:
      Exception
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      指定者:
      afterAll 在接口中 org.junit.jupiter.api.extension.AfterAllCallback
      抛出:
      Exception
    • postProcessTestInstance

      public void postProcessTestInstance(Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Delegates to TestContextManager.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

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      指定者:
      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
      指定者:
      afterTestExecution 在接口中 org.junit.jupiter.api.extension.AfterTestExecutionCallback
      抛出:
      Exception
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      指定者:
      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 the Parameter in the supplied ParameterContext should be autowired from the test's ApplicationContext.

      A parameter is considered to be autowirable if one of the following conditions is true.

      1. The declaring executable is a Constructor and TestConstructorUtils.isAutowirableConstructor(Constructor, Class, PropertyProvider) returns true. Note that isAutowirableConstructor() will be invoked with a fallback PropertyProvider that delegates its lookup to ExtensionContext.getConfigurationParameter(String).
      2. The parameter is of type ApplicationContext or a sub-type thereof.
      3. The parameter is of type ApplicationEvents or a sub-type thereof.
      4. ParameterResolutionDelegate.isAutowirable(java.lang.reflect.Parameter, int) returns true.

      WARNING: If a test class Constructor is annotated with @Autowired or automatically autowirable (see TestConstructor), Infra will assume the responsibility for resolving all parameters in the constructor. Consequently, no other registered ParameterResolver will be able to resolve parameters.

      指定者:
      supportsParameter 在接口中 org.junit.jupiter.api.extension.ParameterResolver
      另请参阅:
    • 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 the Parameter in the supplied ParameterContext by retrieving the corresponding dependency from the test's ApplicationContext.

      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
      另请参阅:
    • getApplicationContext

      public static cn.taketoday.context.ApplicationContext getApplicationContext(org.junit.jupiter.api.extension.ExtensionContext context)
      Get the ApplicationContext associated with the supplied ExtensionContext.
      参数:
      context - the current ExtensionContext (never null)
      返回:
      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 the TestContextManager associated with the supplied ExtensionContext.
      返回:
      the TestContextManager (never null)
    • getStore

      private static org.junit.jupiter.api.extension.ExtensionContext.Store getStore(org.junit.jupiter.api.extension.ExtensionContext context)
    • isAutowiredTestOrLifecycleMethod

      private static boolean isAutowiredTestOrLifecycleMethod(Method method)