Well you can engineer the pointcut potentially using something like a 'cflow' component that makes the advice running conditional on the control flow it finds itself in. But then you would be introducing code that detects whether you are in a test into your woven code, which presumably is what you are going to put into 'production' - and you probably don't want that (do you?)
If you are load time weaving you could just run the tests without the LTW agent in the mix. Why does the advice need to be removed? That may point to the right way to do it. I mean you could just do a system property check in your advice before the body of it executes and then pass in a system property when running tests... I believe people have done the maven solution you are thinking of (not including the aspects when building for a particular test run) but I don't speak enough maven to advise on how to do that. cheers, Andy On 18 April 2014 11:30, Sina <[email protected]> wrote: > Hi there, > > I want to exclude aspectj codes from being executed when I unit test. What > is the best way to do that? > > Manipulating my pointcut such that it does not execute when the caller has > “@Test” annotation? > Using maven goals and exclusion tags? (If so how exactly?) > One note about the possible maven solution: I guess that maven solution > will only help if *"mvn test” * command is run and cannot help when > running the unit test directly (Right clicking on the test file-> Run As > JUnit Test) > > Thanks for the help in advance. > > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > >
_______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
