Skip to content

Commit 9011255

Browse files
committed
Expand doc on @MockBean usage
Closes gh-9609
1 parent d8d156b commit 9011255

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5427,6 +5427,19 @@ classes, on fields within your test, or on `@Configuration` classes and fields.
54275427
on a field, the instance of the created mock will also be injected. Mock beans are
54285428
automatically reset after each test method.
54295429

5430+
[NOTE]
5431+
====
5432+
This feature is automatically enabled as long as your test uses one of Spring Boot's
5433+
test annotations (i.e. `@SpringBootTest`). To use this feature with a different
5434+
arrangement, a listener will need to be added explicitly:
5435+
5436+
[source,java,indent=0]
5437+
----
5438+
@TestExecutionListeners(MockitoTestExecutionListener.class)
5439+
----
5440+
5441+
====
5442+
54305443
Here's a typical example where we replace an existing `RemoteService` bean with a mock
54315444
implementation:
54325445

0 commit comments

Comments
 (0)