spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

When using `@MockitoBean` and `@MockitoSpyBean` make it easier to inject any underlying proxy target as well as the mock or spy

Open wilkinsona opened this issue 5 years ago • 5 comments

We'd like to support something like this:

@MockitoSpyBean
ProxiedBean<Service> service;

ProxiedBean would then provide accessors for the bean both with and without all of its Spring proxies. This should make it easier to bypass any caching or advice when, for example, setting expectations, while having them in place when exercising the service.

Hopefully this will address spring-projects/spring-boot#22281 by providing a nicer API that can be used in place of AopTestUtils.getTargetObject(service).

wilkinsona avatar Aug 05 '20 15:08 wilkinsona