File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
framework-docs/modules/ROOT/pages/testing/annotations/integration-spring Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
1
[[spring-testing-annotation-beanoverriding-mockitobean]]
2
2
= `@MockitoBean` and `@MockitoSpyBean`
3
3
4
- `@MockitoBean` and `@MockitoSpyBean` can be used in test classes to override a bean in
5
- the test's `ApplicationContext` with a Mockito _mock_ or _spy_, respectively. In the
6
- latter case, an early instance of the original bean is captured and wrapped by the spy.
4
+ {spring-framework-api}/test/context/bean/override/mockito/MockitoBean.html[`@MockitoBean`] and
5
+ {spring-framework-api}/test/context/bean/override/mockito/MockitoSpyBean.html[`@MockitoSpyBean`]
6
+ can be used in test classes to override a bean in the test's `ApplicationContext` with a
7
+ Mockito _mock_ or _spy_, respectively. In the latter case, an early instance of the
8
+ original bean is captured and wrapped by the spy.
7
9
8
10
The annotations can be applied in the following ways.
9
11
Original file line number Diff line number Diff line change 1
1
[[spring-testing-annotation-beanoverriding-testbean]]
2
2
= `@TestBean`
3
3
4
- `@TestBean` is used on a non-static field in a test class to override a specific bean in
5
- the test's `ApplicationContext` with an instance provided by a factory method.
4
+ {spring-framework-api}/test/context/bean/override/convention/TestBean.html[`@TestBean`]
5
+ is used on a non-static field in a test class to override a specific bean in the test's
6
+ `ApplicationContext` with an instance provided by a factory method.
6
7
7
8
The associated factory method name is derived from the annotated field's name, or the
8
9
bean name if specified. The factory method must be `static`, accept no arguments, and
You can’t perform that action at this time.
0 commit comments