JaCoCo代码覆盖范围中的设置器和获取器除外 [英] Exclude Setters and Getters in JaCoCo Code Coverage

查看:128
本文介绍了JaCoCo代码覆盖范围中的设置器和获取器除外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 cobertura-maven-plugin ,可以使用 ignoreTrivial 选项将设置和获取方法排除在代码范围之外。 jacoco-maven-plugin 还有这种可能性吗?

With the cobertura-maven-plugin setters and getters can be excluded from code coverage using the ignoreTrivial option. Is there also such a possibility with the jacoco-maven-plugin?

这是我当前的配置:

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.7.1.201405082137</version>
  <configuration>
    <excludes>
      <exclude>com/welovecoding/web/blog/test/**/*.class</exclude>
    </excludes>
  </configuration>
  <executions>
    <execution>
      <id>amend-unit-test-java-agent-option</id>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
    </execution>
    <execution>
      <id>report</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>report</goal>
      </goals>
    </execution>
  </executions>
</plugin>


推荐答案

不正式支持,请参见:

Not supported officialy, see comments in :


https://github.com/jacoco / jacoco / issues / 15

提到的解决方案:


此问题已经存在很长时间了。这是一个非常有趣的功能。例如,它在三叶草和corbetura中实施。有实现过滤的fork:
github.com/huangxiwei/jacoco,
https://github.com/mchr3k / jacoco 从今年年初开始。您为什么不将这些叉子合并到master分支中?即使没有在开始时实施所有过滤,所需的主要过滤器也会在您编写的Wiki页面中列出(尝试使用资源,sync块,枚举静态方法)。覆盖率是一个非常有用的工具,它的累加性越高,它就会越有用。当覆盖率达到很高的价值时,它可以提供很多帮助,它可以帮助您专注于正确的课程。

It's a long time since this issue is opened. It a really interesting feature. For instance it's implemented in clover and corbetura. There are fork that implement filtering : github.com/huangxiwei/jacoco , https://github.com/mchr3k/jacoco since the begining of the year. Why don't you merge those fork into master branch ? Even if all filtering is not implemented at start, main filters needed are listed in the wiki page you have written (Try with resources, sync block, enum static methods). Coverage is a very useful tool, more it's accruate more it's will be usefull. It helps alot when coverage reach a high value, it helps to focus on the right classes.

这篇关于JaCoCo代码覆盖范围中的设置器和获取器除外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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