|
|
|
@ -95,7 +95,7 @@ public class BeanOverrideTestExecutionListener extends AbstractTestExecutionList |
|
|
|
private static void injectFields(TestContext testContext) { |
|
|
|
private static void injectFields(TestContext testContext) { |
|
|
|
Object testInstance = testContext.getTestInstance(); |
|
|
|
Object testInstance = testContext.getTestInstance(); |
|
|
|
// Since JUnit Jupiter 5.12, if the SpringExtension is used with Jupiter's
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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), () -> """ |
|
|
|
Assert.state(applicationContext.containsBean(BeanOverrideRegistry.BEAN_NAME), () -> """ |
|
|
|
Test class %s declares @BeanOverride fields %s, but no BeanOverrideHandler has been registered. \ |
|
|
|
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 \ |
|
|
|
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) |
|
|
|
handlers.stream().map(BeanOverrideHandler::getField).filter(Objects::nonNull) |
|
|
|
.map(Field::getName).toList())); |
|
|
|
.map(Field::getName).toList())); |
|
|
|
BeanOverrideRegistry beanOverrideRegistry = applicationContext.getBean(BeanOverrideRegistry.BEAN_NAME, |
|
|
|
BeanOverrideRegistry beanOverrideRegistry = applicationContext.getBean(BeanOverrideRegistry.BEAN_NAME, |
|
|
|
|