Annotation Interface MockitoSpyBean
Mark a field to trigger a bean override using a Mockito spy, which will wrap
the original instance. If no explicit
name() is specified, the
annotated field's name is interpreted to be the target of the override.
In either case, it is required that the target bean is previously registered
in the context.
Dependencies that are known to the application context but are not beans
(such as those
registered directly) will not be found.
- Since:
- 6.2
- Author:
- Simon Baslé
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe name of the bean to spy.booleanIndicates that Mockito methods such asverify(mock)should use thetargetof AOP advised beans, rather than the proxy itself.The reset mode to apply to the spied bean.
-
Element Details
-
name
String nameThe name of the bean to spy.If not specified, the name of the annotated field will be used.
- Returns:
- the name of the spied bean
- Default:
- ""
-
reset
MockReset resetThe reset mode to apply to the spied bean.The default is
MockReset.AFTERmeaning that spies are automatically reset after each test method is invoked.- Returns:
- the reset mode
- Default:
- AFTER
-
proxyTargetAware
boolean proxyTargetAwareIndicates that Mockito methods such asverify(mock)should use thetargetof AOP advised beans, rather than the proxy itself.Defaults to
true.If set to
falseyou may need to use the result ofAopTestUtils.getUltimateTargetObject(...)when calling Mockito methods.- Returns:
trueif the target of AOP advised beans is used, orfalseif the proxy is used directly
- Default:
- true
-