COMP 4004 Lecture Notes - Lecture 4: Code Coverage, Switch Statement, Unit Testing

21 views3 pages
9 Control Flow Coverage
Method coverage
Statement coverage
Branch coverage (also called decision coverage)
o Minimum coverage specified by the IEEE unit test standard
Multiple Condition coverage
o Covers combinations of condition in decisions
Path coverage
o 100% path coverage impossible in practice (loops)
Flow graph
o The flow graph on the right is determined from the code on the left:
Statement Coverage
o Criterion: All statements must be covered during test execution
o This is the weakest form of coverage
Some branches may be missed
o Find paths that cover all statements
o Choose input data that will result in the selected paths
o Ex. The following path is sufficient for statement coverage:
1 3 4 5 7
Possible input: a = 2, b = 0, x = 4
Branch Coverage
o Criterion: At any branch point, each branch must be covered during test execution
The true and false branch of a 2-way if statement.
Each case in a switch statement.
o Find paths that cover all branches
o Choose input data that will result in the selected paths
o Branch coverage necessarily includes statement coverage
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents