Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
402 views
in Technique[技术] by (71.8m points)

cobertura on maven multi module project

I have a Maven project with 4 modules - 3 of them contain code and some tests (testing equals and hashcode of the classes) whereas the 4th module is for testing the 3 other modules.

Now I want to run the cobertura code coverage tool to get an overview which classes are well tested and which are not. I did some investigations on that topic and it seems that cobertura is not aware of generating the right code coverage percentages and line coverages, if some sources which are tested are located within other modules.

I have read over some links like SeamTestCoverageWithCobertura and Using the plugin Coverage within a multi-module Maven 2 but there has to be an out of the box solution. Can anybody report some new directions on this topic? Or are there bether tools like cobertura? I've stumbled upon emma but this tool does not offer line coverage...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As of version 2.6, there is an aggregate option that can be set to true in the parent pom:

<reporting>
<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <outputDirectory>./target/tmpCobertura</outputDirectory>
        <formats>
            <format>html</format>
        </formats>
        <aggregate>true</aggregate>
    </configuration>
  </plugin>
</plugins>
</reporting>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...