From eb927f1b295950d21c9cbaae57c1e6571e0ea36e Mon Sep 17 00:00:00 2001 From: Aleksander Bartnikiewicz Date: Tue, 1 Nov 2016 20:59:10 +0100 Subject: [PATCH] Prevent a broken factory bean from breaking the resetting of mocks Closes gh-7271 --- .../boot/test/mock/mockito/ResetMocksTestExecutionListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/ResetMocksTestExecutionListener.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/ResetMocksTestExecutionListener.java index 987564ae7c..2d9f257d86 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/ResetMocksTestExecutionListener.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/ResetMocksTestExecutionListener.java @@ -65,7 +65,7 @@ public class ResetMocksTestExecutionListener extends AbstractTestExecutionListen for (String name : names) { BeanDefinition definition = beanFactory.getBeanDefinition(name); if (definition.isSingleton() && instantiatedSingletons.contains(name)) { - Object bean = beanFactory.getBean(name); + Object bean = beanFactory.getSingleton(name); if (reset.equals(MockReset.get(bean))) { Mockito.reset(bean); }