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
- i == 1
- 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
- a true c true
- a true c false
- a false c true
- 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).
9 thoughts on “Whats my Coverage? (C0 C1 C2 C3 + Path)”
Good explanation. Simple and useful
Like the explanation. I also like to think about spec (or scenario) coverage and focus on that.
C1+C2 refers to what?
CX are the various coverage levels, I could not see much of a difference between C2 and C3 so I lumped them together.
What is “i = 1” supposed to be….
was supposed to be `i == 1` 😀