我想看一个例子来阻止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.