Browse Source

Ensure test() conditions in JUnit TestKit match method names

Prior to this commit, the test("test") conditions used in
AutowiredConfigurationErrorsIntegrationTests inadvertently asserted
that the invoked test methods reside in an org.springframework.test
subpackage, which is always the case for any test method in the
`spring-test` module. In other words, "test" is always a substring of
"org.springframework.test...", which is not a meaningful assertion.

This commit ensures that the JUnit Platform Test Kit is asserting the
actual names of test methods.
pull/26087/head
Sam Brannen 4 years ago
parent
commit
48af36c6fa
  1. 10
      spring-test/src/test/java/org/springframework/test/context/junit/jupiter/AutowiredConfigurationErrorsIntegrationTests.java

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

@ -69,7 +69,7 @@ class AutowiredConfigurationErrorsIntegrationTests { @@ -69,7 +69,7 @@ class AutowiredConfigurationErrorsIntegrationTests {
testEventsFor(testClass)
.assertStatistics(stats -> stats.started(1).succeeded(0).failed(1))
.assertThatEvents().haveExactly(1,
event(test("test"),
event(test("test("),
finishedWithFailure(
instanceOf(IllegalStateException.class),
message(msg -> msg.matches(".+must not be annotated with @Autowired.+")))));
@ -87,12 +87,12 @@ class AutowiredConfigurationErrorsIntegrationTests { @@ -87,12 +87,12 @@ class AutowiredConfigurationErrorsIntegrationTests {
.assertStatistics(stats -> stats.started(2).succeeded(0).failed(2))
.assertThatEvents()
.haveExactly(1,
event(test("autowired"),
event(test("autowired(org.junit.jupiter.api.TestInfo)"),
finishedWithFailure(
instanceOf(IllegalStateException.class),
message(msg -> msg.matches(".+must not be annotated with @Autowired.+")))))
.haveExactly(1,
event(test("nonAutowired"),
event(test("nonAutowired(org.junit.jupiter.api.TestInfo)"),
finishedWithFailure(
instanceOf(IllegalStateException.class),
message(msg -> msg.matches(".+must not be annotated with @Autowired.+")))));
@ -256,7 +256,7 @@ class AutowiredConfigurationErrorsIntegrationTests { @@ -256,7 +256,7 @@ class AutowiredConfigurationErrorsIntegrationTests {
@Autowired
@RepeatedTest(1)
void repeatedTest(TestInfo testInfo) {
void test(TestInfo testInfo) {
}
}
@ -278,7 +278,7 @@ class AutowiredConfigurationErrorsIntegrationTests { @@ -278,7 +278,7 @@ class AutowiredConfigurationErrorsIntegrationTests {
@Autowired
@ParameterizedTest
@ValueSource(strings = "ignored")
void parameterizedTest(TestInfo testInfo) {
void test(TestInfo testInfo) {
}
}

Loading…
Cancel
Save