100%分支覆盖率能说明什么(内附思考问题)

参考: 

代码覆盖率浅谈 - CoderZh - 博客园 (cnblogs.com)

100% code coverage! (frankel.ch)

代码覆盖率 ——语句覆盖 Statement Coverage、分支覆盖 Branch Coverage、 路径覆盖 Path Coverage的区别_zhuyutong202的博客-CSDN博客

问题:

 Discuss the following topic:

If all the methods in the source code that are tested and 100% All-Branch coverage is achieved, is it still possible for the program to fail?

If you agree, state some best practices to mitigate the risk of program failure.

回答: 

Yes, I agree with this topic. Because the 100% branch coverage can’t cover all the stations appearing in the program. For example, there is a program.

 

We need 2 test cases to cover the 100% branch coverage, a=5, b=5 and a=10, b=10;

 

However, there are 4 possible return values: 0, 1, 10, 11 in this code, but the branch coverage only tests 2 cases and get the 100%. That is to say, the 100% branch coverage can’t prove these 4 possible return values all are tested, maybe the program will fail when executing the cases that are not be tested. So, if all the methods in the source code that are tested and 100% All-Branch coverage is achieved, it is still possible for the program to fail.

As a result, we should try to get the 100% basis path coverage, which is the most comprehensive and strongest coverage among other coverages such as branch coverage and statement coverage.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值