Cobertura code coverage rate can only be increased otherwise unittest will fail

Cobertura code coverage rate can only be increased

What is Cobertura

Cobertura is a free Java tool that calculates the percentage of code accessed by tests.

问题

Jenkins中集成了Cobertura,code coverage下降unittest就会fail,尽管设置了unstable rate为60%,当code coverage rate高于60%也会fail.

原因

Jenkins pipeline中我们把failUnstable设置成true了,每次Jenkins任务跑完会把mininum stability设置为本次的code coverage值。如果下次run Jenkins任务code coverage低于上一次的minimum stability,就会报error:
ERROR: [Cobertura] Failing build due to unstability.

Action

把failUnstable设置成false,每次Jenkins任务都会把本次的code coverage设置为health minimum和stability minimum:
Lines's new health minimum is: 78.29
Lines's new stability minimum is: 78.29
不再记录上次的stability minimum。

思考

今天又翻了翻资料才发现实cobertura从1.13升级到1.16以后才有的这个问题,原来cobertura期待的行为是The pipeline job will always use the thresholds set in the Jenkinsfile rather than the updated thresholds from previous builds.
在1.13以后修好了这个bug,我们以为的bug是人家的bugfix。

参考

ref: lineCoverageTargets.
Fix: auto update not works when using Pipeline.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值