|
|
|
@ -52,6 +52,15 @@ When using `@MockitoSpyBean` to create a spy for a `FactoryBean`, a spy will be |
|
|
|
for the object created by the `FactoryBean`, not for the `FactoryBean` itself. |
|
|
|
for the object created by the `FactoryBean`, not for the `FactoryBean` itself. |
|
|
|
==== |
|
|
|
==== |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[NOTE] |
|
|
|
|
|
|
|
==== |
|
|
|
|
|
|
|
There are no restrictions on the visibility of `@MockitoBean` and `@MockitoSpyBean` |
|
|
|
|
|
|
|
fields. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Such fields can therefore be `public`, `protected`, package-private (default visibility), |
|
|
|
|
|
|
|
or `private` depending on the needs or coding practices of the project. |
|
|
|
|
|
|
|
==== |
|
|
|
|
|
|
|
|
|
|
|
The following example shows how to use the default behavior of the `@MockitoBean` annotation: |
|
|
|
The following example shows how to use the default behavior of the `@MockitoBean` annotation: |
|
|
|
|
|
|
|
|
|
|
|
[tabs] |
|
|
|
[tabs] |
|
|
|
@ -62,7 +71,7 @@ Java:: |
|
|
|
---- |
|
|
|
---- |
|
|
|
class OverrideBeanTests { |
|
|
|
class OverrideBeanTests { |
|
|
|
@MockitoBean // <1> |
|
|
|
@MockitoBean // <1> |
|
|
|
private CustomService customService; |
|
|
|
CustomService customService; |
|
|
|
|
|
|
|
|
|
|
|
// test case body... |
|
|
|
// test case body... |
|
|
|
} |
|
|
|
} |
|
|
|
@ -86,7 +95,7 @@ Java:: |
|
|
|
---- |
|
|
|
---- |
|
|
|
class OverrideBeanTests { |
|
|
|
class OverrideBeanTests { |
|
|
|
@MockitoBean("service") // <1> |
|
|
|
@MockitoBean("service") // <1> |
|
|
|
private CustomService customService; |
|
|
|
CustomService customService; |
|
|
|
|
|
|
|
|
|
|
|
// test case body... |
|
|
|
// test case body... |
|
|
|
|
|
|
|
|
|
|
|
@ -107,7 +116,7 @@ Java:: |
|
|
|
---- |
|
|
|
---- |
|
|
|
class OverrideBeanTests { |
|
|
|
class OverrideBeanTests { |
|
|
|
@MockitoSpyBean // <1> |
|
|
|
@MockitoSpyBean // <1> |
|
|
|
private CustomService customService; |
|
|
|
CustomService customService; |
|
|
|
|
|
|
|
|
|
|
|
// test case body... |
|
|
|
// test case body... |
|
|
|
} |
|
|
|
} |
|
|
|
@ -130,7 +139,7 @@ Java:: |
|
|
|
---- |
|
|
|
---- |
|
|
|
class OverrideBeanTests { |
|
|
|
class OverrideBeanTests { |
|
|
|
@MockitoSpyBean("service") // <1> |
|
|
|
@MockitoSpyBean("service") // <1> |
|
|
|
private CustomService customService; |
|
|
|
CustomService customService; |
|
|
|
|
|
|
|
|
|
|
|
// test case body... |
|
|
|
// test case body... |
|
|
|
|
|
|
|
|
|
|
|
|