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

前端之家收集整理的这篇文章主要介绍了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.

原文链接:https://www.f2er.com/java/129777.html

猜你在找的Java相关文章