Whats my Coverage? (C0 C1 C2 C3 + Path)

本文转载至: http://grosser.it/2008/04/04/whats-my-coverage-c0-c1-c2-c3-path-coverage/

100% coverage sounds great, but is it c0, c1, c2, c3 or path coverage ? If you do not know, here is the answer:

  • C0 = every instruction
  • C1 = every branch if(i=1) a; even if there is no actual instruction in the i!=1 path it needs 2 tests
    1. i = 1
    2. i != 1
  • C2 + C3 ~= is every condition inside an ‘if’ is once true and once false (personally, i could not care less…)
  • C4: Path-coverage = every possible path was taken, if(a) x else b; if(c) y requires 4 tests
    1. a true c true
    2. a true c false
    3. a false c true
    4. a false c false

Try to aim for ~95% C0 and ~70% C1. C2 and C3 in my opinion add no value(except that they cover more paths) and C4 is often not possible, since a loop can have infinite paths (go through 1,2,3,4… times).

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值