Skip to content

Commit 0f2fc79

Browse files
committed
Update exception message to use correct test class
See gh-35680
1 parent ba70c13 commit 0f2fc79

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void beforeTestMethod(TestContext testContext) throws Exception {
9595
private static void injectFields(TestContext testContext) {
9696
Object testInstance = testContext.getTestInstance();
9797
// Since JUnit Jupiter 5.12, if the SpringExtension is used with Jupiter's
98-
// ExtensionContextScope.TEST_METHOD mode, the value returned from
98+
// TEST_METHOD ExtensionContextScope, the value returned from
9999
// testContext.getTestClass() may refer to the declaring class of the test
100100
// method which is about to be invoked (which may be in a @Nested class
101101
// within the class for the test instance). Thus, we use the class for the
@@ -109,7 +109,7 @@ private static void injectFields(TestContext testContext) {
109109
Assert.state(applicationContext.containsBean(BeanOverrideRegistry.BEAN_NAME), () -> """
110110
Test class %s declares @BeanOverride fields %s, but no BeanOverrideHandler has been registered. \
111111
If you are using @ContextHierarchy, ensure that context names for bean overrides match \
112-
configured @ContextConfiguration names.""".formatted(testContext.getTestClass().getSimpleName(),
112+
configured @ContextConfiguration names.""".formatted(testClass.getSimpleName(),
113113
handlers.stream().map(BeanOverrideHandler::getField).filter(Objects::nonNull)
114114
.map(Field::getName).toList()));
115115
BeanOverrideRegistry beanOverrideRegistry = applicationContext.getBean(BeanOverrideRegistry.BEAN_NAME,

0 commit comments

Comments
 (0)