I’m new to Spring and AOP in Java (though I’ve done some related stuff functionally in the past), so I hope someone can help remedy my ignorance–are there any good guides to unit testing an @Aspect out there? In a related note, is it revealing some profound misunderstanding of the execution model of spring to hope that a breakpoint set within my aspect advice would suspend the debugger and let me look at the variables in scope there? Any old documentation will help, but please be specific… I have read the spring docs, but perhaps I missed the particular bits.
Share
I am assuming that you are using Spring AOP – Using Spring test support you can test AOP related code. Spring AOP works by creating dynamic proxies for your beans which match the pointcut of the advice at runtime, so as long as you are using Spring test support (
@RunWith(SpringJUnit4ClassRunner.class)etc) your @Aspect code should get invoked – You can put breakpoint in an IDE and expect the debugger to suspend when your aspect related breakpoints are reached.