原文:http://www.cnblogs.com/yucongblog/p/5297051.html
1.环境准备
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
</plugins>
</reporting>
...
</project>
2.检查环境是否成功
首先运行“mvn cobertura:help”, 如果不能运行,请添加以下仓库
<project>
...
<pluginRepositories>
<pluginRepository>
<id>Codehaus repository</id>
<url>http://repository.codehaus.org/</url>
</pluginRepository>
</pluginRepositories>
...
</project>
3.进行覆盖率统计
运行mvn coberura:coberura
如果运行成功 请查看{project}\target\site\coberura\index.html
如下图
4.coberura常用命令
下面是cobertura插件的命令
mvn cobertura:help 查看cobertura插件的帮助
mvn cobertura:clean 清空cobertura插件运行结果
mvn cobertura:check 运行cobertura的检查任务
mvn cobertura:cobertura 运行cobertura的检查任务并生成报表,报表生成在target/site/cobertura目录下
cobertura:dump-datafile Cobertura Datafile Dump Mojo
mvn cobertura:instrument Instrument the compiled classes