Pattern Testing with AOP

Discussions

News: Pattern Testing with AOP

  1. Pattern Testing with AOP (3 messages)

    Vincent Massol talks about Pattern Testing, the concept of automatically verifying the good application of architectural/design patterns in code. He discusses how his work in this area resulted in an open source project "Pattern Testing" which uses AOP to get around issues he had with Checkstyle and PMD.

    Excerpt
    Pattern Testing is a concept I started researching in 2002 on a big project at work. At that time, I was already using Checkstyle and PMD to perform verification of rules. However, I was finding them limited in several ways:

    • They were mostly focusing on syntactic rules, whereas I was mostly interested in semantic rule checking. Checkstyle has improved a lot in this area over the past 2 years. However, even though there are some semantic rules , they are usually simple and not very "business"-oriented. Note that this is not to diminish Checkstyle which I find great and use on all projects.
    • They were focusing on applying rules on a single file (using AST trees), whereas I was interested in applying rules that span several files (this is necessary for architectural/design checks). As a consequence writing pattern tests using Checkstyle is difficult.
    • They were limited to static checks. I wanted to be able to say "ensure that no method call is passed a null parameter", "ensure that there are no more than 10 calls to the database per user case", etc
    The result was the Pattern Testing project on SourceForge. It's implemented using AspectJ. It contains some pre-made Pattern Tests but more importantly it lets you write your own. There is Maven plugin that makes it easy to run any Pattern Test on any mavenized project.

    The possibilities of Pattern Testing are endless.
    Visit the Pattern Testing framework

    Threaded Messages (3)

  2. This has lots of potential[ Go to top ]

    I think the idea is great, and there is a lot of potential here. In looking at the samples of things that are testable (http://patterntesting.sourceforge.net/whatis.html) I am impressed. I'm working on a project with all junior developers and I must say I've got my hands full. I think this tool would be very useful. It's amazing some of the stuff I see that could easily be caught by this tool.

    I found one thing lacking on the website: How do we integrate this tool with our application? Do we have to modify any of our code to make it testable? It seems there must be some configuration involved and that point isn't clear on the website. Also, you use AspectJ.. does that mean we have to use AspectJ to write our pattern tests? Any plans to support more dynamic AOP implementations such as AspectWerkz?

    Michael Mattox
  3. This has lots of potential[ Go to top ]

    I'm glad you like it Michael. There are 2 things to understand:

    - there is the concept of writing architectural checks with AOP. This is what I call Pattern Testing. You can do this without any framework. If you're using AspectJ, you can use the AspectJ plugin for your favorite IDE (provided it exists) to weave the Pattern Tests into your code to be tested. If you have a build, you'll need to do the same.

    - there is the Pattern Testing *project* which is there to provide a reusable collection of Pattern Tests (ATM, there are really not much - the one that exist were there for the proof of concept but it would be good to grow this list). The project is also there to contain some tool integration. More specificall build tool integration. ATM, there is one plugin for Maven only. This plugin also allows you to write your own custom Pattern Tests in addtion to using the packaged ones.

    Thus you can start using the Pattern Testing idea immediatly even without using the Pattern Testing *project*.

    As for using other AOP implementations, I'm all for it. It would be good if the Pattern Testing project could become an umbrella for all implementations around Pattern Testing. We just need help to make this a reality... :-)

    Thanks
    -Vincent
  4. Pattern Testing with AOP[ Go to top ]

    Hi,

    I use Eclipse or JBuilder for development. How do I integrate Pattern Testing into these tools? Does the download include samples on how to perform Pattern Testing even if we write code using Notepad?

    regards
    Sridhar