Why isnt branch coverage the same thing as code

This preview shows page 8 - 14 out of 25 pages.

Why isn't branch coverage the same thing as code coverage? Consider an if with no else, or a switch with no default case Line coverage can be achieved without achieving branch coverage
Image of page 8

Subscribe to view the full document.

Complete Condition testing For each compound condition, C Find the simple sub-expressions that make up C Suppose there are n of them Create a test case for all 2 n T/F combinations of the simple sub- expressions If (!done && (value < 100 || c == 'X')) … Simple sub-expressions !done, value < 100, c == 'X' n = 3 Need 8 test cases to test all possibilities
Image of page 9
Complete Condition testing Use a “truth table” to make sure that all possible combinations are covered by your test cases Doing this kind of exhaustive condition testing everywhere is usually not feasible Some combinations might be impossible to achieve (omit these cases, since they are impossible) !done value < 100 c == ‘X’ Case 1: False False False Case 2: True False False Case 3: False True False Case 4: False False True Case 5: True True False Case 6: True False True Case 7: False True True Case 8: True True True
Image of page 10

Subscribe to view the full document.