我使用本指南将Cobertura包含在我的Maven项目中。我将以下内容添加到pom.xml
:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<outputDirectory>${project.build.directory}/surefire-reports/cobertura</outputDirectory>
<instrumentation>
<ignoreTrivial>true</ignoreTrivial>
<ignores>
<ignore>org.slf4j.Logger.*</ignore>
</ignores>
<excludes>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
当我运行构建时,我得到这样的错误:
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file C:\MYSELF\programing\java\AutoCall\AutoClient\target\generated-classes\cobertura\cz\autoclient\autoclick\ComparablePixel.class
java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:147)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)
at net.sourceforge.cobertura.instrument.Main.main(Main.java:421)
它们似乎都在奇怪的文件夹ProjectName\target\generated-classes\cobertura
中,我绝对没有创建。我的报告如下:
当我按Run All Tests
时,我只会遇到与构建期间相同的错误。
这是什么?我的项目需要Cobertura的报告,我必须让它工作。