mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
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 https://github.com/junit-team/junit-framework/issues/5030
Closes gh-35740
This commit is contained in:
+1
-1
@@ -75,7 +75,7 @@ configure([rootProject] + javaProjects) { project ->
|
||||
"https://hc.apache.org/httpcomponents-client-5.5.x/current/httpclient5/apidocs/",
|
||||
"https://projectreactor.io/docs/test/release/api/",
|
||||
"https://junit.org/junit4/javadoc/4.13.2/",
|
||||
"https://docs.junit.org/6.0.0/api/",
|
||||
"https://docs.junit.org/6.0.1/api/",
|
||||
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
|
||||
"https://r2dbc.io/spec/1.0.0.RELEASE/api/",
|
||||
"https://jspecify.dev/docs/api/"
|
||||
|
||||
@@ -19,7 +19,7 @@ dependencies {
|
||||
api(platform("org.eclipse.jetty.ee11:jetty-ee11-bom:12.1.3"))
|
||||
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.2"))
|
||||
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.9.0"))
|
||||
api(platform("org.junit:junit-bom:6.0.0"))
|
||||
api(platform("org.junit:junit-bom:6.0.1"))
|
||||
api(platform("org.mockito:mockito-bom:5.20.0"))
|
||||
api(platform("tools.jackson:jackson-bom:3.0.1"))
|
||||
|
||||
|
||||
@@ -110,9 +110,10 @@ test {
|
||||
// `include` test filters and system properties are configured in
|
||||
// org.springframework.build.TestConventions in buildSrc.
|
||||
filter.excludeTestsMatching("*TestCase")
|
||||
// Override critical severity defined in TestConventions, since spring-test
|
||||
// relies on the Vintage test engine for JUnit 4 support.
|
||||
systemProperty("junit.platform.discovery.issue.severity.critical", "WARNING")
|
||||
// Since spring-test relies on the Vintage test engine for JUnit 4 support,
|
||||
// we disable reporting of the "deprecated" discovery issue, because that
|
||||
// would otherwise fail the build.
|
||||
systemProperty("junit.vintage.discovery.issue.reporting.enabled", "false")
|
||||
// Optionally configure Java Util Logging for the JUnit Platform.
|
||||
// systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
|
||||
}
|
||||
|
||||
+6
-1
@@ -142,7 +142,12 @@ class TestClassScanner {
|
||||
if (packageNames.length > 0) {
|
||||
builder.filters(includePackageNames(packageNames));
|
||||
}
|
||||
LauncherDiscoveryRequest request = builder.build();
|
||||
LauncherDiscoveryRequest request = builder
|
||||
// In case junit.platform.discovery.issue.severity.critical=INFO has been configured,
|
||||
// we do not want scanning to fail due to the deprecation of the Vintage test engine.
|
||||
// So, we disable reporting of the deprecation discovery issue.
|
||||
.configurationParameter("junit.vintage.discovery.issue.reporting.enabled", "false")
|
||||
.build();
|
||||
Launcher launcher = LauncherFactory.create();
|
||||
TestPlan testPlan = launcher.discover(request);
|
||||
|
||||
|
||||
+7
-2
@@ -46,9 +46,14 @@ import org.junit.platform.suite.api.Suite;
|
||||
@SelectPackages("org.springframework.test.context")
|
||||
@IncludeClassNamePatterns(".*Tests?$")
|
||||
@ExcludeTags("failing-test-case")
|
||||
@ConfigurationParameter(
|
||||
key = "junit.platform.discovery.issue.severity.critical",
|
||||
value = "INFO")
|
||||
@ConfigurationParameter(
|
||||
key = "junit.vintage.discovery.issue.reporting.enabled",
|
||||
value = "false")
|
||||
@ConfigurationParameter(
|
||||
key = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME,
|
||||
value = "org.junit.jupiter.api.ClassOrderer$ClassName"
|
||||
)
|
||||
value = "org.junit.jupiter.api.ClassOrderer$ClassName")
|
||||
class SpringTestContextFrameworkTestSuite {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user