From 90112559bf8d47ae30c7eaab1235b54697814be2 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 27 Jun 2017 16:59:16 +0200 Subject: [PATCH] Expand doc on `@MockBean` usage Closes gh-9609 --- .../src/main/asciidoc/spring-boot-features.adoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 59a5ae32e2..ae68dc5c32 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -5427,6 +5427,19 @@ classes, on fields within your test, or on `@Configuration` classes and fields. on a field, the instance of the created mock will also be injected. Mock beans are automatically reset after each test method. +[NOTE] +==== +This feature is automatically enabled as long as your test uses one of Spring Boot's +test annotations (i.e. `@SpringBootTest`). To use this feature with a different +arrangement, a listener will need to be added explicitly: + +[source,java,indent=0] +---- + @TestExecutionListeners(MockitoTestExecutionListener.class) +---- + +==== + Here's a typical example where we replace an existing `RemoteService` bean with a mock implementation: