java – JaCoCo并错过了私有默认构造函数的覆盖范围

我想看一个例子来阻止JaCoCo将私有空构造函数报告为 Java类中的非覆盖代码.

在我的maven插件配置中

<rule>
     <element>CLASS</element>
       <excludes>
         <exclude>JAVAC.SYNTHCLASS</exclude>
         <exclude>JAVAC.SYNTHMETH</exclude>
       </excludes>
     </element>
   </rule>

是不是有类似的构造函数

解决方法

这不受支持. official documentation说:

Filters for Code where Test Execution is Questionable or Impossible by Design

  • Private,empty default constructors – assuming no calls to it
  • Plain getters and setters
  • Blocks that throw AssertionErrors – Entire block should be ignored if a condition (if !assertion throw new AssertionError)

另见:https://github.com/jacoco/jacoco/issues/298

更新:这在https://github.com/jacoco/jacoco/pull/529修复,应该在0.8.0.

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...