diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockBean.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockBean.java index d82a419d46..1a323240aa 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockBean.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,12 @@ import org.springframework.test.context.junit4.SpringRunner; * or test classes that are {@link RunWith @RunWith} the {@link SpringRunner}. *

* Mocks can be registered by type or by {@link #name() bean name}. Any existing single - * bean of the same type defined in the context will be replaced by the mock, if no - * existing bean is defined a new one will be added. + * bean of the same type defined in the context will be replaced by the mock. If no + * existing bean is defined a new one will be added. Dependencies that are known to the + * application context but are not beans (such as those + * {@link org.springframework.beans.factory.config.ConfigurableListableBeanFactory#registerResolvableDependency(Class, Object) + * registered directly} ) will not be found and a mocked bean will be added to the context + * alongside the existing dependency. *

* When {@code @MockBean} is used on a field, as well as being registered in the * application context, the mock will also be injected into the field. Typical usage might diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyBean.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyBean.java index 1b7cc5fa6c..759e179f71 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyBean.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,11 @@ import org.springframework.test.context.junit4.SpringRunner; *

* Spies can be applied by type or by {@link #name() bean name}. All beans in the context * of the same type will be wrapped with the spy. If no existing bean is defined a new one - * will be added. + * will be added. Dependencies that are known to the application context but are not beans + * (such as those + * {@link org.springframework.beans.factory.config.ConfigurableListableBeanFactory#registerResolvableDependency(Class, Object) + * registered directly} ) will not be found and a spied bean will be added to the context + * alongside the existing dependency. *

* When {@code @SpyBean} is used on a field, as well as being registered in the * application context, the spy will also be injected into the field. Typical usage might