Closed slawek-mazur closed 2 years ago
Hi @slawek-mazur
My guess is that it's the same issue as https://github.com/Ninja-Squad/springmockk/issues/85. But I'm still waiting for a minimal repro or test case allowing me to debug (and hopefully fix) the issue. Please take some time to provide one.
hello.
sure thing, please take a look at this minimal PoC
https://github.com/slawek-mazur/mockk-spykbean
it is indeed related to that enrichment $$EnhancerBySpringCGLIB$$
where CustomService
becomes com.example.demo.CustomService$$EnhancerBySpringCGLIB$$
if I comment out like so 👇 there's no AOP and CGLIB doesn't kick in with it's proxies.
@Configuration
//@EnableAsync
class ExecutorConfig
@slawek-mazur thanks for the repro. You're indeed hitting the same issue with AOP-modified Spring beans which exists since day 1 (see the first limitation listed in the README), and that I have no idea how to fix. Sorry for that.
There's a test case, BTW, that comes from Spring Boot and which is disabled because it fails, see https://github.com/Ninja-Squad/springmockk/blob/master/src/test/kotlin/com/ninjasquad/springmockk/SpyBeanWithAopProxyTests.kt#L39).
In your specific case, you should be able to workaround the issue by using confirmVerified(AopTestUtils.getUltimateTargetObject(service))
or confirmVerified(AopTestUtils.getTargetObject(service))
. But this is a hack.
Unless someone can finally find a solution for this, my only advice would be to find a workaround. I generally thend to avoid spies in the first place.
Fair enough, thanks for the support.
in test
it works perfectly fine when