[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Defining pointcuts or aspects within a normal java class
|
Hi
I am a total newbie to AspectJ, so apologies in advance if this
question is stupid.
Quick question - Is either of the above possible and how?
If more explanation is required then read on -
I want to create an aspect for unit testing that can be used to
replace method call return values with mock objects. I can do this
already but I have to define the mocks, pointcuts and advice in an
aspect and define separate pointcuts and advice for each object I
want to replace. The downside is that looking at the test function it
is not clear what is going on and I am defining a lot of around
advice which essentially all does the same thing -(return a mock for
a given pointcut). I was thinking that maybe it would be possible to
make a method call within the test class, having for parameters a
list of mock objects and a list of pointcuts, which is intercepted by
an aspect that exposes the pointcuts and objects and can then use
around advice on the specified pointcuts to replace the return values
of those calls with the mock objects.
Or I would like to define an aspect within my test class so that it
can have access to all the mock objects used.
Thanks
Piers