Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce TestClassScanner to locate Spring test classes for AOT processing #28824

Closed
5 tasks done
sbrannen opened this issue Jul 14, 2022 · 0 comments
Closed
5 tasks done
Assignees
Labels
in: test Issues in the test module theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Jul 14, 2022

Overview

Similar to the org.springframework.aot.test.build.TestClassesFinder from the Spring Native project, we need something that can scan the classpath (from classpath roots provided by the user or build tool) to locate Spring test classes.

Related Issues

Deliverables

  • Introduce TestClassScanner in spring-test that effectively scans the classpath for Spring test classes using the Launcher API from the JUnit Platform (JUnit 5).
  • Find JUnit Jupiter test classes annotated with @ExtendWith(SpringExtension.class).
  • Find JUnit 4 test classes annotated with @RunWith(SpringRunner.class) or @RunWith(SpringJUnit4ClassRunner.class).
  • Find other test classes (for example, TestNG) annotated with @ContextConfiguration or @BootstrapWith.
  • Ensure that test classes are properly detected within JUnit Platform @Suite hierarchies.
@sbrannen sbrannen added in: test Issues in the test module type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing labels Jul 14, 2022
@sbrannen sbrannen added this to the 6.0.0-M6 milestone Jul 14, 2022
@sbrannen sbrannen self-assigned this Jul 14, 2022
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jul 15, 2022
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jul 15, 2022
…essing

This commit introduces the TestClassScanner which 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.

Closes spring-projectsgh-28824
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jul 15, 2022
The search algorithm for @ExtendWith should not be tied to Spring's
@NestedTestConfiguration semantics. Rather, general JUnit annotation
search semantics should be used to find @ExtendWith.

See spring-projectsgh-28824
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jul 15, 2022
- remove not-empty precondition check for packageNames so that the core
  scan() method can actually be used.
- document constructor
- document use case for packageNames
- add test that scan's all test classes in the spring-test project
- reduce logging due to the previous action item

See spring-projectsgh-28824
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant