jacoco插件配置单测覆盖率计算排除某个类
时间: 2023-09-10 21:05:10 浏览: 241
要在使用Jacoco插件时排除某个类的单元测试覆盖率计算,你可以在`<build>`标签内添加以下代码:
```xml
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<excludes>
<exclude>com/example/MyClass.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<excludes>
<exclude>com/example/MyClass.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
```
其中,`<excludes>`标签内的内容为要排除的类的路径。例如,要排除`com.example.MyClass`类,就将`<exclude>`标签内的内容设置为`com/example/MyClass.java`。
阅读全文