Monday, 13. October 2008
Hello World with PatternTesting
Logo for PatternTestingIf you want to use Patterntesting with Eclipse you must install the AspectJ plugin AJDT. If you haven't done it add the site http://download.eclipse.org/tools/ajdt/34/update for Eclipse 3.4 and install it.

Now we are ready to create a simple Java project with a hello.World class inside:
package hello;
public class World {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Before we can add the PatternTesting library we must convert the project into a AspectJ project. Select "AspectJ Tools > Convert to AspectJ Project" from the project's context menu (right mouse key).

Next we will integrate the PatternTesting library. Download it from the download page and call the project properties. Select the entry "AspectJ Build" and then the tab "Aspect Path". Add the patterntesting.0.6.0.jar you have downloaded and press ok.


You should see now the warning No logging should be done using System.out! in the problems view. I don't know any program which needs to use System.out for printing so this warning is normally ok. One exception from this rule is this Hello-World program so you can suppress it using the anntoation @SystemOutNeeded:
package hello;
import patterntesting.java.annotation.*;
public class World {
    @SystemOutNeeded
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

happy patterntesting...

... link (0 Kommentare)   ... comment