Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: How to prevent AJDT from weaving some class?

Another big issue is about the mock object:

expect(obj.addNewString("ABC")).andReturn("ABC");

AJDT weaves the advice into this line, but the mock object doesn't work before replay(obj) is called. When you run the unit test, you will get null instead of "ABC".

MyAspect: before adding new data
MyAspect: add ABC and got null

So the aspect doesn't work correctly for mock objects. 

On Thu, May 20, 2010 at 10:59 AM, Benyi Wang <bewang.tech@xxxxxxxxx> wrote:
It seems that AJDT tries to weave all classes in a project by default.

I attached files in a test project.

When I use "call" for pointcuts of interface Addable in MyAspect, AJDT tries to weave the interface calls of the mock object. Sometimes I don't want the advices in my unit test code, for example, advices from the log aspect. 

How can I prevent AJDT from weaving junit test case classes?

I did a test in my Eclipse 3.5 with AJDT 2.0.2.

If I add aop.xml into project properties->AspectJ Builder->aop.xml Management, some wired things happens:
  1. all aspectj advice markers are gone. You need to clean the project first, otherwise you may see the markers are still there.
  2. if you clean the project "Project->clean...", only the files under src/main/java are compiled, src/test/java are not compiled.
  3. remove aop.xml from aop.xml management, everything comes back.
What's wrong in my project? Is this AJDT bug?

Thanks.

Ben


Back to the top