为你的POM添加
<!-- 覆盖率 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
<aggregate>true</aggregate>
<formats>
<format>xml</format>
<format>html</format>
</formats>
<instrumentation>
<excludes>
<exclude>**/*Proto.class</exclude>
<exclude>**/*Proto$*.class</exclude>
<exclude>**/*Test.class</exclude>
<exclude>**/*Controller.class</exclude>
<exclude>**/*Vo.class</exclude>
<exclude>**/*Form.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
具体可参考:
https://github.com/knightliao/disconf/blob/master/disconf-web/pom.xml
先写生成覆盖率的脚本:
覆盖率报告: