Skip to content

Commit 324b254

Browse files
committed
Upgrade to JUnit 6.0.1 and prevent AOT scanning failure for JUnit 4 tests
This commit upgrades our test suite to use JUnit 6.0.1 and removes the systemProperty("junit.platform.discovery.issue.severity.critical", "WARNING") configuration from spring-test.gradle, so that all discovery issues will fail the build for the spring-test module as well. In addition, this commit prevents potential AOT test scanning failures for JUnit 4 tests by setting the "junit.vintage.discovery.issue.reporting.enabled" configuration parameter to "false" in TestClassScanner. See junit-team/junit-framework#5030 Closes gh-35740
1 parent f2cfc69 commit 324b254

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ configure([rootProject] + javaProjects) { project ->
7575
"https://hc.apache.org/httpcomponents-client-5.5.x/current/httpclient5/apidocs/",
7676
"https://projectreactor.io/docs/test/release/api/",
7777
"https://junit.org/junit4/javadoc/4.13.2/",
78-
"https://docs.junit.org/6.0.0/api/",
78+
"https://docs.junit.org/6.0.1/api/",
7979
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
8080
"https://r2dbc.io/spec/1.0.0.RELEASE/api/",
8181
"https://jspecify.dev/docs/api/"

framework-platform/framework-platform.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies {
1919
api(platform("org.eclipse.jetty.ee11:jetty-ee11-bom:12.1.3"))
2020
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.2"))
2121
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.9.0"))
22-
api(platform("org.junit:junit-bom:6.0.0"))
22+
api(platform("org.junit:junit-bom:6.0.1"))
2323
api(platform("org.mockito:mockito-bom:5.20.0"))
2424
api(platform("tools.jackson:jackson-bom:3.0.1"))
2525

spring-test/spring-test.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ test {
110110
// `include` test filters and system properties are configured in
111111
// org.springframework.build.TestConventions in buildSrc.
112112
filter.excludeTestsMatching("*TestCase")
113-
// Override critical severity defined in TestConventions, since spring-test
114-
// relies on the Vintage test engine for JUnit 4 support.
115-
systemProperty("junit.platform.discovery.issue.severity.critical", "WARNING")
113+
// Since spring-test relies on the Vintage test engine for JUnit 4 support,
114+
// we disable reporting of the "deprecated" discovery issue, because that
115+
// would otherwise fail the build.
116+
systemProperty("junit.vintage.discovery.issue.reporting.enabled", "false")
116117
// Optionally configure Java Util Logging for the JUnit Platform.
117118
// systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
118119
}

spring-test/src/main/java/org/springframework/test/context/aot/TestClassScanner.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ Stream<Class<?>> scan(String... packageNames) {
142142
if (packageNames.length > 0) {
143143
builder.filters(includePackageNames(packageNames));
144144
}
145-
LauncherDiscoveryRequest request = builder.build();
145+
LauncherDiscoveryRequest request = builder
146+
// In case junit.platform.discovery.issue.severity.critical=INFO has been configured,
147+
// we do not want scanning to fail due to the deprecation of the Vintage test engine.
148+
// So, we disable reporting of the deprecation discovery issue.
149+
.configurationParameter("junit.vintage.discovery.issue.reporting.enabled", "false")
150+
.build();
146151
Launcher launcher = LauncherFactory.create();
147152
TestPlan testPlan = launcher.discover(request);
148153

spring-test/src/test/java/org/springframework/test/context/SpringTestContextFrameworkTestSuite.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@
4646
@SelectPackages("org.springframework.test.context")
4747
@IncludeClassNamePatterns(".*Tests?$")
4848
@ExcludeTags("failing-test-case")
49+
@ConfigurationParameter(
50+
key = "junit.platform.discovery.issue.severity.critical",
51+
value = "INFO")
52+
@ConfigurationParameter(
53+
key = "junit.vintage.discovery.issue.reporting.enabled",
54+
value = "false")
4955
@ConfigurationParameter(
5056
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
51-
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
52-
)
57+
value = "org.junit.jupiter.api.ClassOrderer$ClassName")
5358
class SpringTestContextFrameworkTestSuite {
5459
}

0 commit comments

Comments
 (0)