mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Update exception message to use correct test class
See gh-35680
This commit is contained in:
+2
-2
@@ -95,7 +95,7 @@ public class BeanOverrideTestExecutionListener extends AbstractTestExecutionList
|
||||
private static void injectFields(TestContext testContext) {
|
||||
Object testInstance = testContext.getTestInstance();
|
||||
// Since JUnit Jupiter 5.12, if the SpringExtension is used with Jupiter's
|
||||
// ExtensionContextScope.TEST_METHOD mode, the value returned from
|
||||
// TEST_METHOD ExtensionContextScope, the value returned from
|
||||
// testContext.getTestClass() may refer to the declaring class of the test
|
||||
// method which is about to be invoked (which may be in a @Nested class
|
||||
// within the class for the test instance). Thus, we use the class for the
|
||||
@@ -109,7 +109,7 @@ public class BeanOverrideTestExecutionListener extends AbstractTestExecutionList
|
||||
Assert.state(applicationContext.containsBean(BeanOverrideRegistry.BEAN_NAME), () -> """
|
||||
Test class %s declares @BeanOverride fields %s, but no BeanOverrideHandler has been registered. \
|
||||
If you are using @ContextHierarchy, ensure that context names for bean overrides match \
|
||||
configured @ContextConfiguration names.""".formatted(testContext.getTestClass().getSimpleName(),
|
||||
configured @ContextConfiguration names.""".formatted(testClass.getSimpleName(),
|
||||
handlers.stream().map(BeanOverrideHandler::getField).filter(Objects::nonNull)
|
||||
.map(Field::getName).toList()));
|
||||
BeanOverrideRegistry beanOverrideRegistry = applicationContext.getBean(BeanOverrideRegistry.BEAN_NAME,
|
||||
|
||||
Reference in New Issue
Block a user