From 48af36c6fa7408e917cc837734499293ea2f96ad Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 12 Nov 2020 15:11:54 +0100 Subject: [PATCH] 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. --- .../AutowiredConfigurationErrorsIntegrationTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/AutowiredConfigurationErrorsIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/AutowiredConfigurationErrorsIntegrationTests.java index e49221470d..35dd5e8f5e 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/AutowiredConfigurationErrorsIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/AutowiredConfigurationErrorsIntegrationTests.java @@ -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 { .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 { @Autowired @RepeatedTest(1) - void repeatedTest(TestInfo testInfo) { + void test(TestInfo testInfo) { } } @@ -278,7 +278,7 @@ class AutowiredConfigurationErrorsIntegrationTests { @Autowired @ParameterizedTest @ValueSource(strings = "ignored") - void parameterizedTest(TestInfo testInfo) { + void test(TestInfo testInfo) { } }