Class TestClassScanner

java.lang.Object
org.springframework.test.context.aot.TestClassScanner

public class TestClassScanner extends Object
TestClassScanner scans provided classpath roots for Spring 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 Spring integration test classes.

  • JUnit Jupiter: classes that register the SpringExtension via @ExtendWith.
  • JUnit 4: classes that register the SpringJUnit4ClassRunner or SpringRunner 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
Since:
6.0
Author:
Sam Brannen
  • Constructor Details

    • TestClassScanner

      public 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.

      Parameters:
      classpathRoots - the classpath roots to scan
  • Method Details

    • scan

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