2009-09-02 6 views
3

誰もAspectjプラグインとCoberturaプラグインでmaven2を使用できましたか?私は何かを得るべきであるとき、私は0%のカバレッジを得続けます。 Asbertj製織の前にCobertura計測器が稼働していると思いますが、これはCobertura計測器を台無しにしています。また、Coberturaは自分の側面について警告を出しています。Javaファイルとして解析しようとしているようです。どんな助けもありがとう。maven coberturaはaspectjを使って0%を報告します

 
C:\project>mvn cobertura:cobertura 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Project 
[INFO] task-segment: [cobertura:cobertura] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Preparing cobertura:cobertura 
[INFO] [aspectj:compile {execution: compile}] 
[INFO] [resources:resources] 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 1 resource 
[INFO] [compiler:compile] 
[INFO] Nothing to compile - all classes are up to date 
[INFO] [cobertura:instrument] 
[INFO] Cobertura 1.9.2 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file 
Cobertura: Loaded information on 538 classes. 
Instrumenting 538 files to C:\project\target\generated-classes\cobertura 
Cobertura: Saved information on 538 classes. 
Instrument time: 3938ms 

[INFO] Instrumentation was successful. 
[INFO] [aspectj:test-compile {execution: test-compile}] 
[INFO] [resources:testResources] 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 1 resource 
[INFO] [compiler:testCompile] 
[INFO] Nothing to compile - all classes are up to date 
[INFO] [surefire:test] 
[INFO] Surefire report directory: C:\project\target\surefire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running project.AnnounceTypeActionTest 

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.594 sec 

Results : 

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 

[INFO] [cobertura:cobertura] 
[INFO] Cobertura 1.9.2 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file 
Cobertura: Loaded information on 538 classes. 
Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 5, column 8. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 

[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\ApplicationLoggingAspect.aj 
ParseException in STDIN 
Last useful checkpoint: "project.logging." 
Encountered "aspect" at line 5, column 8. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 


Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 4, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 

[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\LoggingAspect.aj 
ParseException in STDIN 
Last useful checkpoint: "project.logging." 
Encountered "aspect" at line 4, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 


Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 6, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 

[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\TracingAspect.aj 
ParseException in STDIN 
Last useful checkpoint: "project.logging." 
Encountered "aspect" at line 6, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 


Report time: 5891ms 

[INFO] Cobertura Report generation was successful. 
[INFO] Cobertura 1.9.2 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file 
Cobertura: Loaded information on 538 classes. 
Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 5, column 8. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 

[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\ApplicationLoggingAspect.aj 
ParseException in STDIN 
Last useful checkpoint: "project.logging." 
Encountered "aspect" at line 5, column 8. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 


Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 4, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 

[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\LoggingAspect.aj 
ParseException in STDIN 
Last useful checkpoint: "project.logging." 
Encountered "aspect" at line 4, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 


Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 6, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 

[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\TracingAspect.aj 
ParseException in STDIN 
Last useful checkpoint: "project.logging." 
Encountered "aspect" at line 6, column 17. 
Was expecting one of: 
    "@" ... 
    "abstract" ... 
    "final" ... 
    "public" ... 
    "synchronized" ... 
    "strictfp" ... 
    "class" ... 
    "static" ... 
    "protected" ... 
    "private" ... 
    "native" ... 
    "transient" ... 
    "volatile" ... 
    "enum" ... 
    "interface" ... 


Report time: 3125ms 

[INFO] Cobertura Report generation was successful. 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 30 seconds 
[INFO] Finished at: Wed Sep 02 17:15:45 VET 2009 
[INFO] Final Memory: 26M/254M 
[INFO] ------------------------------------------------------------------------ 
+0

"Coberturaの計測は、AspectJの織りの前に実行されています"あなたは積み込み時間を使っていますか? –

答えて

2

私は、コンパイルのためにaspectj-maven-pluginを設定し、コードカバレッジにcobertura-maven-pluginを使用してプロジェクトを設定しました。コンパイル時にはmvn siteを実行しても正常に動作しますが、テストはCobertura製織を可能にするために2回コンパイル/実行されます。

次の出力での結果、以下の構成でmvn siteの実行:

[INFO] Preparing surefire-report:report 
[INFO] [aspectj:compile {execution: compile_with_aspectj}] 
... 
[INFO] [compiler:compile] 
[INFO] Nothing to compile - all classes are up to date 
... 
[INFO] [compiler:testCompile {execution: test-compile}] 
[INFO] Compiling 8 source files to C:\test\aop-test 
[INFO] [aspectj:test-compile {execution: test-compile_with_aspectj}] 
... 
[INFO] [surefire:test] 
... 
[INFO] Preparing cobertura:cobertura 
[INFO] [aspectj:compile {execution: compile_with_aspectj}] 
... 
[INFO] [compiler:compile] 
[INFO] Nothing to compile - all classes are up to date 
[INFO] [cobertura:instrument] 
[INFO] Cobertura 1.8 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file 
Instrumenting 11 files to C:\test\aop-test\generated-classes\cobertura 
Cobertura: Saved information on 11 classes. 
Instrument time: 250ms 

[INFO] Instrumentation was successful. 
[INFO] [compiler:testCompile {execution: test-compile}] 
[INFO] Nothing to compile - all classes are up to date 
[INFO] [aspectj:test-compile {execution: test-compile_with_aspectj}] 
... 
[INFO] [surefire:test] 
... 
Cobertura: Coverage data file C:\test\aop-test\cobertura.ser either 
    does not exist or is not readable. Creating a new data file. 
Cobertura: Saved information on 8 classes. 

私の設定は以下に含まれています。

あなたの側面のCoberturaの警告に関しては、アドバイス実行の本体を側面で定義するのではなく、Java型に移動することができます。例えば

ではなく、このやって:代わりに、あなたはJava型に実装を委任することができ、そのプロセスへの局面では、ほとんどのコードがある

before(Throwable e, Object subject): handlers(e, subject) { 
    Log logger = getTraceLog(subject.getClass()); 

    //code to trace exception handling 
    ... 
} 

を:

before(Throwable e, Object subject): handlers(e, subject) { 
    Log logger = getTraceLog(subject.getClass()); 

    //get helper type and delegate processing to that type. 
    getFormatterHelper().traceErrorHandling(logger, thisJoinPoint, e); 
} 

マイ設定アスペクトとコベルトーラのプラグインの場合:

<build> 
    <plugins> 
    ... 
    <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>aspectj-maven-plugin</artifactId> 
     <version>1.2</version> 
     <executions> 
     <execution> 
      <id>compile_with_aspectj</id> 
      <goals> 
      <goal>compile</goal> 
      </goals> 
      <configuration> 
      <complianceLevel>1.5</complianceLevel> 
      </configuration> 
     </execution> 
     <execution> 
      <id>test-compile_with_aspectj</id> 
      <goals> 
      <goal>test-compile</goal> 
      </goals> 
      <configuration> 
      <complianceLevel>1.5</complianceLevel> 
      </configuration> 
     </execution> 
     </executions> 
     <dependencies> 
     <dependency> 
      <groupId>aspectj</groupId> 
      <artifactId>aspectjtools</artifactId> 
      <version>1.6.4</version> 
     </dependency> 
     </dependencies> 
    </plugin> 
    </plugins> 
</build> 
... 
<reporting> 
    <plugins> 
    ... 
    <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>cobertura-maven-plugin</artifactId> 
     <version>2.1</version> 
     <configuration> 
     <formats> 
      <format>html</format> 
      <format>xml</format> 
     </formats> 
     <outputDirectory>target/site/cobertura</outputDirectory> 
     </configuration> 
    </plugin> 
    <plugins 
</reporting> 
0

私は同じ問題を抱えていますカバレッジはHudson上で報告されました)、aspectjの実行目標から "テストコンパイル"目標を取り除いて解決しました。その後、CoberturaとEmmaの両方が魅力的な働きをしました。

マイAspectJのセクション:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>aspectj-maven-plugin</artifactId> 
    <version>1.3</version> 
    <executions> 
    <execution> 
     <goals> 
     <goal>compile</goal> 
     <!-- <goal>test-compile</goal> --> 
     </goals> 
    </execution> 
    </executions> 
    <configuration> 
    <source>1.6</source> 
    <weaveWithAspectsInMainSourceFolder>true</weaveWithAspectsInMainSourceFolder> 
    <weaveMainSourceFolder>true</weaveMainSourceFolder> 
    </configuration> 
</plugin> 

マイCoberturaのセクション:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>cobertura-maven-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
    <formats> 
     <format>xml</format> 
    </formats> 
    </configuration> 
</plugin> 

そして、念のため、私のエマセクション:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>emma-maven-plugin</artifactId> 
    <version>1.0-alpha-2</version> 
</plugin> 
関連する問題