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
This commit is contained in:
parent
ad2b7f4d01
commit
7606a929c9
|
@ -62,7 +62,8 @@ class TestConventions {
|
|||
test.include("**/*Tests.class", "**/*Test.class");
|
||||
test.setSystemProperties(Map.of(
|
||||
"java.awt.headless", "true",
|
||||
"io.netty.leakDetection.level", "paranoid"
|
||||
"io.netty.leakDetection.level", "paranoid",
|
||||
"junit.platform.discovery.issue.severity.critical", "INFO"
|
||||
));
|
||||
if (project.hasProperty("testGroups")) {
|
||||
test.systemProperty("testGroups", project.getProperties().get("testGroups"));
|
||||
|
|
|
@ -65,11 +65,9 @@ class AutowiredConfigurationErrorsIntegrationTests {
|
|||
@ParameterizedTest
|
||||
@ValueSource(classes = {
|
||||
StaticAutowiredBeforeAllMethod.class,
|
||||
StaticAutowiredPrivateBeforeAllMethod.class,
|
||||
StaticAutowiredAfterAllMethod.class,
|
||||
AutowiredBeforeEachMethod.class,
|
||||
AutowiredAfterEachMethod.class,
|
||||
AutowiredPrivateAfterEachMethod.class,
|
||||
AutowiredTestMethod.class,
|
||||
AutowiredRepeatedTestMethod.class,
|
||||
AutowiredParameterizedTestMethod.class
|
||||
|
@ -168,21 +166,6 @@ class AutowiredConfigurationErrorsIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
@SpringJUnitConfig(Config.class)
|
||||
@FailingTestCase
|
||||
static class StaticAutowiredPrivateBeforeAllMethod {
|
||||
|
||||
@Autowired
|
||||
@BeforeAll
|
||||
private static void beforeAll(TestInfo testInfo) {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName(DISPLAY_NAME)
|
||||
void test() {
|
||||
}
|
||||
}
|
||||
|
||||
@SpringJUnitConfig(Config.class)
|
||||
@TestInstance(PER_CLASS)
|
||||
@FailingTestCase
|
||||
|
@ -260,22 +243,6 @@ class AutowiredConfigurationErrorsIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
@SpringJUnitConfig(Config.class)
|
||||
@FailingTestCase
|
||||
static class AutowiredPrivateAfterEachMethod {
|
||||
|
||||
@Test
|
||||
@DisplayName(DISPLAY_NAME)
|
||||
void test() {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@AfterEach
|
||||
private void afterEach(TestInfo testInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SpringJUnitConfig(Config.class)
|
||||
@FailingTestCase
|
||||
static class AutowiredTestMethod {
|
||||
|
|
Loading…
Reference in New Issue