Skip to content

Commit 22b73f3

Browse files
committed
Polish "Improve documentaion of Mockito test execution listeners"
See gh-25375
1 parent 72562e0 commit 22b73f3

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6593,7 +6593,7 @@ To use this feature with a different arrangement, listeners must be explicitly a
65936593
65946594
[source,java,indent=0]
65956595
----
6596-
@TestExecutionListeners({MockitoTestExecutionListener.class, ResetMocksTestExecutionListener.class})
6596+
@TestExecutionListeners({ MockitoTestExecutionListener.class, ResetMocksTestExecutionListener.class })
65976597
----
65986598
65996599
====

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListener.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@
3333
import org.springframework.util.ReflectionUtils.FieldCallback;
3434

3535
/**
36-
* {@link TestExecutionListener} to trigger {@link MockitoAnnotations#initMocks(Object)}
37-
* when {@link MockBean @MockBean} annotations are used. Primarily to allow
38-
* {@link Captor @Captor} annotations.
36+
* {@link TestExecutionListener} to enable {@link MockBean @MockBean} and
37+
* {@link SpyBean @SpyBean} support. Also triggers
38+
* {@link MockitoAnnotations#initMocks(Object)} when any Mockito annotations used,
39+
* primarily to allow {@link Captor @Captor} annotations.
40+
* <p>
41+
* To use the automatic reset support of {@code @MockBean} and {@code @SpyBean}, configure
42+
* {@link ResetMocksTestExecutionListener} as well.
3943
*
4044
* @author Phillip Webb
4145
* @author Andy Wilkinson
4246
* @since 1.4.2
47+
* @see ResetMocksTestExecutionListener
4348
*/
4449
public class MockitoTestExecutionListener extends AbstractTestExecutionListener {
4550

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/ResetMocksTestExecutionListener.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,10 +35,11 @@
3535

3636
/**
3737
* {@link TestExecutionListener} to reset any mock beans that have been marked with a
38-
* {@link MockReset}.
38+
* {@link MockReset}. Typically used alongside {@link MockitoTestExecutionListener}.
3939
*
4040
* @author Phillip Webb
4141
* @since 1.4.0
42+
* @see MockitoTestExecutionListener
4243
*/
4344
public class ResetMocksTestExecutionListener extends AbstractTestExecutionListener {
4445

0 commit comments

Comments
 (0)