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

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).

5 thoughts on “Whats my Coverage? (C0 C1 C2 C3 + Path)”

1. Sibi says:

Good explanation. Simple and useful

2. Coffee_fan says:

Like the explanation. I also like to think about spec (or scenario) coverage and focus on that.

3. Narasimha says:

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.