Cobertura在Maven多模块项目上 [英] cobertura on maven multi module project

查看:158
本文介绍了Cobertura在Maven多模块项目上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有4个模块的Maven项目-其中3个包含代码和一些测试(测试类的equals和hashcode),而第4个模块用于测试其他3个模块.

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.

现在,我想运行cobertura代码覆盖率工具以概述哪些类经过了很好的测试,哪些没有经过良好的测试.我对该主题进行了一些调查,如果某些经过测试的源位于其他模块中,那么cobertura似乎并没有意识到生成正确的代码覆盖率和行覆盖率.

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.

我已经阅读了一些链接,例如 SeamT​​estCoverageWithCobertura

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...

推荐答案

从2.6版开始,有一个聚合选项可以在父pom中设置为true:

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>

这篇关于Cobertura在Maven多模块项目上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆