Skip to content

Commit 7606a92

Browse files
committed
Fail build for JUnit discovery issues
JUnit 5.13 introduced support for Discovery Issues which typically indicate configuration errors in tests that may result in unexpected behavior. Furthermore, discovery issues that are currently reported at INFO level may later be reported at WARNING or ERROR level -- for example, in JUnit 6. In order to ensure that our test suite does not suffer from such potential errors, this commit sets the junit.platform.discovery.issue.severity.critical JVM system property to INFO (instead of leaving it with the default ERROR configuration). Doing so aligns with our build configuration which fails the build for selected warnings in Java source code and Javadoc. If we later determine that INFO causes unnecessary issues for us, we can switch to WARNING. This commit also removes two "intentionally invalid" test cases from AutowiredConfigurationErrorsIntegrationTests, since those test cases are now reported as invalid as of JUnit 5.13. Closes gh-35107
1 parent ad2b7f4 commit 7606a92

File tree

2 files changed

+2
-34
lines changed

2 files changed

+2
-34
lines changed

buildSrc/src/main/java/org/springframework/build/TestConventions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ private void configureTests(Project project, Test test) {
6262
test.include("**/*Tests.class", "**/*Test.class");
6363
test.setSystemProperties(Map.of(
6464
"java.awt.headless", "true",
65-
"io.netty.leakDetection.level", "paranoid"
65+
"io.netty.leakDetection.level", "paranoid",
66+
"junit.platform.discovery.issue.severity.critical", "INFO"
6667
));
6768
if (project.hasProperty("testGroups")) {
6869
test.systemProperty("testGroups", project.getProperties().get("testGroups"));

spring-test/src/test/java/org/springframework/test/context/junit/jupiter/AutowiredConfigurationErrorsIntegrationTests.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ class AutowiredConfigurationErrorsIntegrationTests {
6565
@ParameterizedTest
6666
@ValueSource(classes = {
6767
StaticAutowiredBeforeAllMethod.class,
68-
StaticAutowiredPrivateBeforeAllMethod.class,
6968
StaticAutowiredAfterAllMethod.class,
7069
AutowiredBeforeEachMethod.class,
7170
AutowiredAfterEachMethod.class,
72-
AutowiredPrivateAfterEachMethod.class,
7371
AutowiredTestMethod.class,
7472
AutowiredRepeatedTestMethod.class,
7573
AutowiredParameterizedTestMethod.class
@@ -168,21 +166,6 @@ void test() {
168166
}
169167
}
170168

171-
@SpringJUnitConfig(Config.class)
172-
@FailingTestCase
173-
static class StaticAutowiredPrivateBeforeAllMethod {
174-
175-
@Autowired
176-
@BeforeAll
177-
private static void beforeAll(TestInfo testInfo) {
178-
}
179-
180-
@Test
181-
@DisplayName(DISPLAY_NAME)
182-
void test() {
183-
}
184-
}
185-
186169
@SpringJUnitConfig(Config.class)
187170
@TestInstance(PER_CLASS)
188171
@FailingTestCase
@@ -260,22 +243,6 @@ void afterEach(TestInfo testInfo) {
260243
}
261244
}
262245

263-
@SpringJUnitConfig(Config.class)
264-
@FailingTestCase
265-
static class AutowiredPrivateAfterEachMethod {
266-
267-
@Test
268-
@DisplayName(DISPLAY_NAME)
269-
void test() {
270-
}
271-
272-
@Autowired
273-
@AfterEach
274-
private void afterEach(TestInfo testInfo) {
275-
}
276-
}
277-
278-
279246
@SpringJUnitConfig(Config.class)
280247
@FailingTestCase
281248
static class AutowiredTestMethod {

0 commit comments

Comments
 (0)