Jacoco - 忽略 MyClass.1

Jacoco - ignore MyClass.1

如何在 Jacoco 覆盖范围内忽略 *.1 类?

我的 POM 中有以下内容:

<execution>
  <id>JaCoco Coverage Enforcement</id>
  <phase>verify</phase>
  <goals>
    <goal>check</goal>
  </goals>
  <configuration>
  <dataFile>${project.build.directory}/coverage-reports/jacoco-unit.exec</dataFile>
  <excludes>
    <exclude>**/MyClass.**</exclude>
  </excludes>
  <rules>
    ...
  </rules>
</execution>

但是,我收到以下错误消息:

[WARNING] Rule violated for class com.mypackage.MyClass.1: lines covered ratio is 0.00, but expected minimum is 0.85

更新 12/19

文件夹结构如下:

$ find . -iname 'MyClass*class'
./target/classes/com/mypackage/MyClass.class
./target/classes/com/mypackage/MyClass.class

Exclusion pattern for verify goal 可以是 **/MyClass$** 如果您只想排除文件 MyClass.class(请注意美元符号,您有点)。如果要同时排除 MyClass.classMyClass.class,则 pattern 可以是 **/MyClass**.