[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Test-Driven Development and Aspect Oriented Programming
|
Hello,
On Saturday 18 January 2003 20:19, stephen bodnar wrote:
> Greetings,
>
> I'm looking for some pointers on using Test-Driven Development
> and AspectJ. I've only recently started studying AOP.
>
> I would basically like to be able to TDD Aspects, however, I have some
> questions:
> Since Aspects cannot be instantiated, the only part of a given aspect that
> can
> be tested, by Junit, would be the aspect's static members. Is this correct?
In a nutshell: No.
Aspects are automatically instantiated by the "runtime system" of AspectJ.
So you need to create the aspect via executing a pointcut method, storing the
aspect in some well know location and from there on you can thest the member
functions of the aspects. However that is only a part of the story. what is
much more important to test, if the aspect as a hole does what it should do.
For this specific purpose, you need some colaborating objects, which are used
with the test cases.
>
> Also, I was wondering if it is possible to TDD the definition of a
> pointcut. For example, to be able to test that the given point cut
> definition includes certain execution points and excludes certain other
> execution points using JUnit's TestCases.
If a pointcut should not include some specific execution points, I exclude
this execution point from the pointcut.
If a pointcut should include some specific execution points, I simply
enumerate them and let the compiler check with -Xlint.
I am not aware of any other natural way, except testing the
end2end-functionality, in which the aspect is involved, if the crosscutting
aspect logic works as designed. You will end up with writting crosscutting
tests for modularised code, which was former crosscutting. However if you can
aford that, I bet you do not need AOP. ;-)
As a sidenote: In all OO-based systems, I have seen these tests are not
implemented there either, if the crosscutting functionality is even
implemented.
Please correct me if I am wrong.
Do you write test cases for every very randomly executing try{}catch()
statements?
Summing up in a nutshell:
AOP forces you to tailor your testing policies for TDD.
kind regards
Arno
******************************************************************************
Arno Schmidmeier
+49/9151/90 50 30
or A@xxxxxxxxxxxxxxx
******************************************************************************
Yes, I have realized several projects with AspectJ.
Yes, I do provide consulting for AspectJ.
>
> It would be great if anybody could point me to some resources answering
> these kinds of questions.
>
> Thanks,
> Stephen Bodnar
>
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
--