测试覆盖率插件cobertura-maven-plugin

maven的测试覆盖率插件集成,首先修改工程的pom.xml文件,添加cobertura-maven-plugin插件,如下:

1.环境准备

?
1
2
3
4
5
6
7
8
9
10
11
12
13
< 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”, 如果不能运行,请添加以下仓库

?
1
2
3
4
5
6
7
8
9
10
< 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插件的命令

?
1
2
3
4
5
6
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
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值