-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Overview
As I mentioned in commit e384389, our TestConventions implementation currently overrides any pre-configured JUnit Platform options in an existing Gradle test task.
Actually, it overrides any existing test task configuration that TestConventions also happens to set. So, this is not limited to JUnit Platform options, but the JUnit Platform options are typically the most important configuration options that should be retained.
spring-framework/buildSrc/src/main/java/org/springframework/build/TestConventions.java
Lines 52 to 67 in cdee5c5
| private void configureTests(Project project, Test test) { | |
| test.useJUnitPlatform(); | |
| test.include("**/*Tests.class", "**/*Test.class"); | |
| test.setSystemProperties(Map.of( | |
| "java.awt.headless", "true", | |
| "io.netty.leakDetection.level", "paranoid" | |
| )); | |
| if (project.hasProperty("testGroups")) { | |
| test.systemProperty("testGroups", project.getProperties().get("testGroups")); | |
| } | |
| test.jvmArgs( | |
| "--add-opens=java.base/java.lang=ALL-UNNAMED", | |
| "--add-opens=java.base/java.util=ALL-UNNAMED", | |
| "-Xshare:off" | |
| ); | |
| } |
Specifically, TestConventions overrides configuration for the test tasks in spring-context.gradle and spring-test.gradle. Consequently, configuration such as includeEngines "junit-jupiter", "junit-vintage" is not honored, and the test task will erroneously succeed without the presence of the JUnit Vintage test engine, which will silently ignore tests such as SpringAtInjectTckTests (for the @Inject TCK) and all JUnit 4 tests in the spring-test module.
Thus, we should revise the implementation of TestConventions so that existing JUnit options are copied instead of overridden.
Related Issues
- Move build test configuration to Gradle convention (commit 9562a1c)
- Reinstate the
@InjectTechnology Compatibility Kit (TCK) #34800