Statement Coverage:: Weakness
Statement Coverage:: Weakness
Statement Coverage:: Weakness
Slide 14B.1
Statement coverage:
Running a set of test cases in which every statement is e
xecuted at least once
A CASE tool needed to keep track
Weakness
Branch statements
Problem:
The number of paths may be very large
Disadvantage:
Upper bound on number of paths is 2d, where d is the number of br
anches
In practice:
The actual number of paths is proportional to d
It may not be p
ossible to test
a specific state
ment
We may have
an infeasible p
ath (“dead cod
e”) in the artifa
ct
Frequently this
is evidence of
a fault
Example
The tester believes each line of code has a 2 percent ch
ance of containing a fault.
If the artifact under test is 100 lines long, then it is expe
cted to contain 2 faults
Experiments comparing
Black-box testing
Glass-box testing
Reviews
[Hwang, 1981]
All three methods were equally effective
Professional programmers
Code reading detected more faults
Code reading had a faster fault detection rate
Conclusion
Code inspection is at least as successful at detecting
faults as glass-box and black-box testing
A typical object:
About 30 methods, some with only 2 or 3 statements
A method often does not return a value to the caller — it change
s state instead
It may not be possible to check the state because of information
hiding
Example: Method determineBalance — we need to know accou
ntBalance before, after
Java implementati
on of a tree hierar
chy
Top half
Bottom
half
Figure 9.17
Bad news
BinaryTree.displayNodeContents must be retested fro
m scratch when reused in method BalancedBinaryTree
It invokes a different version of printRoutine
Worse news
For theoretical reasons, we need to test using totally diff
erent test cases
Figure 9.18
[Myers, 1979]
47% of the faults in OS/370 were in only 4% of the mod
ules
[Endres, 1975]
512 faults in 202 modules of DOS/VS (Release 28)
112 of the modules had only one fault
There were modules with 14, 15, 19 and 28 faults, resp
ectively
The latter three were the largest modules in the product,
with over 3000 lines of DOS macro assembler language
The module with 14 faults was relatively small, and very
unstable
A prime candidate for discarding, redesigning, recoding
© The McGraw-Hill Companies, 2005
When to Rewrite Rather Than Debug (contd) Slide 14B.27
Examples:
QAPartner
XRunner