More than Just Lines on a Map: Best Practices for U.S Bike Routes
Lec.unit testing control flow
1. UNIT TESTING - Complexity
Reference:
+ Software Testing Course @ Lonsdale System
+Structured Testing: A Testing Methodology Using
the Cyclomatic Complexity Metric
@ Arthur: H. Watson + Thomas J. McCabe
1
2. Control flow graphs
Cyclomatic complexity can be used
for 2 purposes:
As a defect prevention technique
To determine the number of
structural test cases that will execute
all of independent paths through a
program
2
HCMUNS – FIT – SE Dept - ST Course
5. Cyclomatic complexity
Complexity = number of edges –
number of nodes + 2
Sequence = 1-2+2 =1
If … then ... Else = (2-2+2) = 2
Repeat … until = (3-3+2) = 2
While do … end = (3-3+2) = 2
Case = (7-5+2) = 4
5
HCMUNS – FIT – SE Dept - ST Course
16. Alternative Approaches to Counting
Complexity
Too simple
Complexity = number of decision
predicates + 1
Let check examples again !
16
HCMUNS – FIT – SE Dept - ST Course