vendredi 20 mars 2015

AspectJ with JUnit tests by inpathing the main project

I have downloaded a large project (Whiley) and am wanting to Trace every method that is executed during the projects JUnit Tests.


There are 6 modules and they rely on each other mostly.


I am currently trying to get a single module working using Eclipse AspectJ plugin.


My aspectJ Inpath settings


Inpath Settings


AspectJ weaves the code and produces the compiled version of wyc in the /bin folder.


However, when I try and run the JUnit test's .class file through the CLI.


With the following statement:



java -cp "C:\Users\name\git\WhileyCompiler\lib\junit-4.11.jar";"C:\Users\name\git\WhileyCompiler\lib\*.jar";"C:\Users\name\git\WhileyCompiler\lib\hamcrest-all-1.3.jar" org.junit.runner.JUnitCore "C:\Users\name\git\Test\bin\wyc\testing\AllValidTests.class"


I get the following:


Error


My aspect file



pointcut traceMethods() : (execution(* *(..))&& !cflow(within(Trace)));

before(): traceMethods(){
Signature sig = thisJoinPointStaticPart.getSignature();
String line =""+ thisJoinPointStaticPart.getSourceLocation().getLine();
String sourceName = thisJoinPointStaticPart.getSourceLocation().getWithinType().getCanonicalName();
service.addMethodCall(sourceName);
Logger.getLogger("Tracing").log(
Level.INFO,
"Call from "
+ sourceName
+" line " +
line
+" to " +sig.getDeclaringTypeName() + "." + sig.getName()
);
}

Aucun commentaire:

Enregistrer un commentaire