CoberturaInstrumenter - 无法检测文件?

day*_*mer 11 java code-coverage maven

我的项目正在使用Java 1.8maven 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>
Run Code Online (Sandbox Code Playgroud)

然后我做

 mvn clean cobertura:cobertura  
Run Code Online (Sandbox Code Playgroud)

我看到了以下

[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] --------------------------------------------------------  
Run Code Online (Sandbox Code Playgroud)

最后它说

Cobertura: Loaded information on 0 classes.
Run Code Online (Sandbox Code Playgroud)

这里有什么不对?

jlb*_*jlb 12

更新05/10/2015:截至目前版本2.7(显然)支持这一点 - 谢谢@tomasz_kusmierczyk

看起来这是因为Cobertura 2.0.3依赖于ASM 4.1,它不支持Java 8.我设法通过强制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>
Run Code Online (Sandbox Code Playgroud)

正确的方法可能是使用不同的代码覆盖工具,例如JaCoCo,它意味着支持Java 8.

更新:如果沿着这条路线走下去,看起来你会丢失一些代码覆盖率信息,所以另一个CC工具确实是要走的路.

  • 为了澄清您丢失的代码覆盖率信息/丢失的功能:1)如果代码具有lambda表达式,则整个类的代码复杂度变为0.2)Instrumentation创建了大量的错误输出,但仍然成功. - 据我所知,即使在lambda中,线路覆盖数仍然被正确记录. (2认同)