类 TestClassScanner

java.lang.Object
cn.taketoday.test.context.aot.TestClassScanner

class TestClassScanner extends Object
TestClassScanner scans provided classpath roots for Infra integration test classes using the JUnit Platform Launcher API which allows all registered TestEngines to discover tests according to their own rules.

The scanner currently detects the following categories of Infra integration test classes.

  • JUnit Jupiter: classes that register the InfraExtension via @ExtendWith.
  • JUnit 4: classes that register the InfraJUnit4ClassRunner or InfraRunner via @RunWith.
  • Generic: classes that are annotated with @ContextConfiguration or @BootstrapWith.

The scanner has been tested with the following TestEngines.

  • JUnit Jupiter
  • JUnit Vintage
  • JUnit Platform Suite Engine
  • TestNG Engine for the JUnit Platform
从以下版本开始:
4.0
作者:
Sam Brannen, Harry Yang
  • 字段详细资料

    • EXTEND_WITH_ANNOTATION_NAME

      private static final String EXTEND_WITH_ANNOTATION_NAME
      另请参阅:
    • SPRING_EXTENSION_NAME

      private static final String SPRING_EXTENSION_NAME
      另请参阅:
    • RUN_WITH_ANNOTATION_NAME

      private static final String RUN_WITH_ANNOTATION_NAME
      另请参阅:
    • SPRING_JUNIT4_CLASS_RUNNER_NAME

      private static final String SPRING_JUNIT4_CLASS_RUNNER_NAME
      另请参阅:
    • SPRING_RUNNER_NAME

      private static final String SPRING_RUNNER_NAME
      另请参阅:
    • logger

      private final cn.taketoday.logging.Logger logger
    • classpathRoots

      private final Set<Path> classpathRoots
  • 构造器详细资料

    • TestClassScanner

      TestClassScanner(Set<Path> classpathRoots)
      Create a TestClassScanner for the given classpath roots.

      For example, in a Gradle project that only supports Java-based tests, the supplied set would contain a single Path representing the absolute path to the project's build/classes/java/test folder.

      参数:
      classpathRoots - the classpath roots to scan
  • 方法详细资料

    • scan

      Stream<Class<?>> scan()
      Scan the configured classpath roots for Infra integration test classes.
    • scan

      Stream<Class<?>> scan(String... packageNames)
      Scan the configured classpath roots for Infra integration test classes in the given packages.

      This method is currently only intended to be used within our own test suite to validate the behavior of this scanner with a limited scope. In production scenarios one should invoke scan() to scan all packages in the configured classpath roots.

    • getJavaClass

      private Optional<Class<?>> getJavaClass(org.junit.platform.engine.support.descriptor.ClassSource classSource)
    • isInfraTestClass

      private boolean isInfraTestClass(Class<?> clazz)
    • isJupiterInfraTestClass

      private static boolean isJupiterInfraTestClass(Class<?> clazz)
    • isJUnit4InfraTestClass

      private static boolean isJUnit4InfraTestClass(Class<?> clazz)
    • isGenericInfraTestClass

      private static boolean isGenericInfraTestClass(Class<?> clazz)
    • assertPreconditions

      private static Set<Path> assertPreconditions(Set<Path> classpathRoots)