我的项目正在使用Java 1.8
和maven 3.2.1
我使用Corbetura
插件作为
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<format>xml</format>
<maxmem>256m</maxmem>
<aggregate>true</aggregate>
<outputDirectory>shippable/codecoverage</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<reportsDirectory>shippable/testresults</reportsDirectory>
</configuration>
</plugin>
然后我做
mvn clean cobertura:cobertura
我看到以下
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] 'usePluginRegistry' is deprecated and has no effect. @ /Users/harith/.m2/settings.xml
[WARNING]
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Oauth: Assembling Modules
[INFO] OAuth: Persistence
[INFO] OAuth: Business
[INFO] OAuth: REST
[INFO] OAuth: Integration Tests
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Oauth: Assembling Modules 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ oauth ---
[INFO] Deleting /Users/harith/code/IdeaProjects/others/oauth/target
[INFO]
[INFO] >>> cobertura-maven-plugin:2.6:cobertura (default-cli) @ oauth >>>
[INFO]
[INFO] --- cobertura-maven-plugin:2.6:instrument (default-cli) @ oauth ---
[INFO] Skipping cobertura mojo for project with packaging type 'pom'
[INFO]
[INFO] <<< cobertura-maven-plugin:2.6:cobertura (default-cli) @ oauth <<<
[INFO]
[INFO] --- cobertura-maven-plugin:2.6:cobertura (default-cli) @ oauth ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OAuth: Persistence 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ persistence ---
[INFO] Deleting /Users/harith/code/IdeaProjects/others/oauth/persistence/target
[INFO]
[INFO] >>> cobertura-maven-plugin:2.6:cobertura (default-cli) @ persistence >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ persistence ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/harith/code/IdeaProjects/others/oauth/persistence/target/classes
[INFO]
[INFO] --- cobertura-maven-plugin:2.6:instrument (default-cli) @ persistence ---
[INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/persistence/target/generated-classes/cobertura/com/self/oauth/persistence/entities/services/OauthEntityManager.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)
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/persistence/target/generated-classes/cobertura/com/self/oauth/persistence/entities/services/OauthEntityManagerProducer.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)
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/persistence/target/generated-classes/cobertura/com/self/oauth/persistence/entities/User.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)
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/persistence/target/generated-classes/cobertura/com/self/oauth/persistence/entities/UserService.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)
[ERROR] Aug 13, 2014 11:21:26 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler saveCoverageData
INFO: Cobertura: Saved information on 0 classes.
[INFO] Instrumentation was successful.
[INFO] NOT adding cobertura ser file to attached artifacts list.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ persistence ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/harith/code/IdeaProjects/others/oauth/persistence/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ persistence ---
[INFO] Surefire report directory: /Users/harith/code/IdeaProjects/others/oauth/persistence/shippable/testresults
[INFO] Using configured provider org.apache.maven.surefire.junit4.JUnit4Provider
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.self.oauth.persistence.entities.UserServiceTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.404 sec - in com.self.oauth.persistence.entities.UserServiceTest
Results :
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] <<< cobertura-maven-plugin:2.6:cobertura (default-cli) @ persistence <<<
[INFO]
[INFO] --- cobertura-maven-plugin:2.6:cobertura (default-cli) @ persistence ---
[INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Report time: 40ms
[ERROR] Aug 13, 2014 11:21:28 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData
INFO: Cobertura: Loaded information on 0 classes.
[INFO] Cobertura Report generation was successful.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OAuth: Business 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ business ---
[INFO] Deleting /Users/harith/code/IdeaProjects/others/oauth/business/target
[INFO]
[INFO] >>> cobertura-maven-plugin:2.6:cobertura (default-cli) @ business >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ business ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/harith/code/IdeaProjects/others/oauth/business/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ business ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/harith/code/IdeaProjects/others/oauth/business/target/classes
[INFO]
[INFO] --- cobertura-maven-plugin:2.6:instrument (default-cli) @ business ---
[INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/business/target/generated-classes/cobertura/com/self/oauth/business/oauth/ClientRegistrationManager.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)
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/business/target/generated-classes/cobertura/com/self/oauth/business/oauth/TokenManager.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)
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/business/target/generated-classes/cobertura/com/self/oauth/business/oauth/UniqueIdGenerator.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)
[cobertura] WARN [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /Users/harith/code/IdeaProjects/others/oauth/business/target/generated-classes/cobertura/com/self/oauth/business/outbound/ClientDetail.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)
[ERROR] Aug 13, 2014 11:21:29 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler saveCoverageData
INFO: Cobertura: Saved information on 0 classes.
[INFO] Instrumentation was successful.
[INFO] NOT adding cobertura ser file to attached artifacts list.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ business ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ business ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/harith/code/IdeaProjects/others/oauth/business/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ business ---
[INFO] Surefire report directory: /Users/harith/code/IdeaProjects/others/oauth/business/shippable/testresults
[INFO] Using configured provider org.apache.maven.surefire.junit4.JUnit4Provider
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.self.oauth.business.oauth.ClientRegistrationManagerTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.608 sec - in com.self.oauth.business.oauth.ClientRegistrationManagerTest
Running com.self.oauth.business.oauth.TokenManagerTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.15 sec - in com.self.oauth.business.oauth.TokenManagerTest
Running com.self.oauth.business.oauth.UniqueIdGeneratorTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec - in com.self.oauth.business.oauth.UniqueIdGeneratorTest
Results :
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OAuth: Integration Tests 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ integration ---
[INFO] Deleting /Users/harith/code/IdeaProjects/others/oauth/integration/target
[INFO]
[INFO] >>> cobertura-maven-plugin:2.6:cobertura (default-cli) @ integration >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ integration ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ integration ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- sql-maven-plugin:1.5:execute (default) @ integration ---
[INFO] Executing commands
[INFO] 1 of 1 SQL statements executed successfully
[INFO]
[INFO] --- cobertura-maven-plugin:2.6:instrument (default-cli) @ integration ---
[WARNING] No files to instrument.
[INFO] NOT adding cobertura ser file to attached artifacts list.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ integration ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/harith/code/IdeaProjects/others/oauth/integration/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ integration ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/harith/code/IdeaProjects/others/oauth/integration/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ integration ---
[INFO] Surefire report directory: /Users/harith/code/IdeaProjects/others/oauth/integration/shippable/testresults
[INFO] Using configured provider org.apache.maven.surefire.junit4.JUnit4Provider
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] <<< cobertura-maven-plugin:2.6:cobertura (default-cli) @ integration <<<
[INFO]
[INFO] --- cobertura-maven-plugin:2.6:cobertura (default-cli) @ integration ---
[INFO] Executing aggregate cobertura:report for Oauth: Assembling Modules
Aug 13, 2014 11:21:33 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData
INFO: Cobertura: Loaded information on 0 classes.
Aug 13, 2014 11:21:33 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData
INFO: Cobertura: Loaded information on 0 classes.
Aug 13, 2014 11:21:33 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData
INFO: Cobertura: Loaded information on 0 classes.
[INFO] Saving aggregate cobertura information in /Users/harith/code/IdeaProjects/others/oauth/target/cobertura/cobertura.ser
Aug 13, 2014 11:21:33 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler saveCoverageData
INFO: Cobertura: Saved information on 0 classes.
[INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Report time: 42ms
[ERROR] Aug 13, 2014 11:21:33 AM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData
INFO: Cobertura: Loaded information on 0 classes.
[INFO] Cobertura Report generation was successful.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Oauth: Assembling Modules ......................... SUCCESS [ 0.597 s]
[INFO] OAuth: Persistence ................................ SUCCESS [ 3.532 s]
[INFO] OAuth: Business ................................... SUCCESS [ 2.784 s]
[INFO] OAuth: REST ....................................... SUCCESS [ 0.694 s]
[INFO] OAuth: Integration Tests .......................... SUCCESS [ 0.976 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.784 s
[INFO] Finished at: 2014-08-13T11:21:33-08:00
[INFO] Final Memory: 28M/101M
[INFO] --------------------------------------------------------
最后它说
Cobertura: Loaded information on 0 classes.
这里有什么问题?
答案 0 :(得分:11)
2015年5月10日更新:截至目前版本2.7(显然)支持此功能 - 感谢@tomasz_kusmierczyk
看起来这是因为Cobertura 2.0.3依赖于ASM 4.1,它不支持Java 8.我设法&#34;修复&#34;这通过强制cobertura-maven-plugin使用ASM 5.0.3,但我并不完全确定这是正确的做事方式。然而它确实摆脱了所有这些警告。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
...
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.3</version>
</dependency>
</dependencies>
</plugin>
正确的方法可能是使用不同的代码覆盖率工具,例如JaCoCo,这意味着支持Java 8。
更新:如果您沿着这条路线走下去,看起来会丢失一些代码覆盖率信息,因此确实是另一种CC工具。
答案 1 :(得分:0)
来自https://github.com/cobertura/cobertura/wiki/FAQ#classnotfoundexception-during-instrumentation:
“这是因为在cobertura 2.0中的检测过程中,我们使用ASM来重建.class文件。我们重建了stackmap,这是与java 7兼容的要求。这并不意味着我们重新编译代码但是ASM要求我们提供其他类的二进制文件以防它需要查找任何超级方法。为了解决这个问题,我们使用一个名为auxClasspath的参数。“
将以下代码添加到ant文件(build.xml)应解决此问题。
<path id="cobertura.auxpath">
<pathelement location="${bin}"/>
</path>
<target name="instrument_coverage" depends="init_coverage"
description="Instruments source code for coverage measurement">
<cobertura-instrument datafile="${coverage.datafile}">
<fileset refid="coverage-files"/>
<auxClasspath>
<path refid="cobertura.auxpath" />
</auxClasspath>
</cobertura-instrument>
</target>
这对我有用。