Title: White Box Basics
1White Box Basics Part 3
2COVERAGE Simple Structure
What did we learn so far ? We found out a lot
about Statement Coverage Anweisungsüberdeckung B
ranch Coverage Zweigüberdeckung Path
Coverage Pfadüberdeckung We are not
so sure about Branch Conditions
3COVERAGE Simple Structure
We had a close look at some simple structures. I
called them Mickey Mouse structures
4COVERAGE Simple Structure
5COVERAGE Simple Structure
proc1
proc2
proc3
6COVERAGE Simple Structure
NOT SO SIMPLE ANY MORE
7COMPLEXITY
- We have to find a
- Measure for the
- Complexity of our
- Test Objects
8COMPLEXITY
9COMPLEXITY
THIS IS AN
EDGE
KANTE
10COMPLEXITY
THIS IS A
NODE
KNOTEN
11COMPLEXITY
EDGES
12COMPLEXITY
EDGES
NODES
13COMPLEXITY
EDGES
NODES
14COMPLEXITY
EDGES
NODES
EDGE ?
15COMPLEXITY
EDGES
NODES
NODE ?
16COMPLEXITY
NODE
EDGES
NODES
17COMPLEXITY
NODE
EDGES
NODES
18COMPLEXITY
NODE
EDGES
NODES
19COMPLEXITY
EDGES
NODES
20COMPLEXITY
This looks too simple
Lets make it look like it was made by a GENIUS
!
21COMPLEXITY
22COMPLEXITY
Lets tidy this up !
23COMPLEXITY
24COMPLEXITY
25COMPLEXITY
We have got four NODES
26COMPLEXITY
e1
e2
e4
e3
We have got four EDGES
27COMPLEXITY
e1
e2
e4
e3
n 4 e 4 e n 0
28COMPLEXITY
n 6 e 6 e n 0
Lets add Terminators
29COMPLEXITY
- We have added two nodes
- We have added two edges
- We did not add complexity
n 6 e 6 e n 0
n 4 e 4 e n 0
30COMPLEXITY
n 6 e 6 e n 0
Control Flow Graph
Kontrollfluss-Graph
Now lets give it a nice Name
31COMPLEXITY
n 6 e 7 e n 1
32COMPLEXITY
n 7 e 8 e n 1
33COMPLEXITY
n 11 e 13 e n 2
34COMPLEXITY
- The Difference Edges - Nodes
- gives us a clue about Complexity
n 11 e 13 e n 2
n 4 e 4 e n 0
35COMPLEXITY
n 6 e 5 e n -1
36COMPLEXITY
Do you think this structure has
NEGATIVE Complexity ?
37COMPLEXITY
I think it rather has ZERO Complexity
38COMPLEXITY
- The Difference Edges - Nodes
- gives us a clue about Complexity
e n 1
39COMPLEXITY
Professor McCabe says it has a Complexity of ONE
40COMPLEXITY
- I do not want to argue about that
e n 2
41COMPLEXITY
- Cyclomatic Complexity
- Zyklomatische Zahl
e n 2
42COMPLEXITY
This measure is often used for Risk Analysis
Cyclomatic Complexity Risk Evaluation
1-10 a simple program, without much risk
11-20 more complex, moderate risk
21-50 complex, high risk program
greater than 50 untestable program (very high risk)
43COMPLEXITY
CC 1 We will need 1 Case for Statement Coverage
44COMPLEXITY
CC 1 C0 1 We will need 1 Case
for Branch Coverage
45COMPLEXITY
CC 1 C0 1 C1 1 We will need 1 Case
for Path Coverage
46COMPLEXITY
CC 1 C0 1 C1 1 C2 1
47COMPLEXITY
n 6 e 6 e n 0 CC 2
48COMPLEXITY
CC 2 C0 1 C1 2 C2 2
49COMPLEXITY
CC 3 C0 1 C1 2 C2 4
50COMPLEXITY
n 11 e 13 e n 2
51COMPLEXITY
CC 4 C0 ? C1 ? C2 ?
52COMPLEXITY
CC 4 C0 ? C1 ? C2 ?
3 Test Cases for Statement Coverage
53COMPLEXITY
CC 4 C0 3 C1 ? C2 ?
3 Test Cases for Branch Coverage
54COMPLEXITY
CC 4 C0 3 C1 3 C2 ?
6 Test Cases for Path Coverage
55COMPLEXITY
CC 4 C0 3 C1 3 C2 6
56COMPLEXITY
n 8 e 10 e n 2
57COMPLEXITY
CC 4 C0 ? C1 ? C2 ?
n 8 e 10 e n 2
58COMPLEXITY
CC 4 C0 ? C1 ? C2 ?
1 Test Case for Statement Coverage
59COMPLEXITY
CC 4 C0 1 C1 ? C2 ?
3 Test Cases for Branch Coverage
60COMPLEXITY
CC 4 C0 1 C1 3 C2 ?
6 Test Cases for Path Coverage
61COMPLEXITY
CC 4 C0 1 C1 3 C2 6
62COMPLEXITY
CC 3 C0 1 C1 2 C2 4
CC 2 C0 1 C1 2 C2 2
CC 1 C0 1 C1 1 C2 1
CC 4 C0 1 C1 3 C2 6
CC 4 C0 3 C1 3 C2 6
CC 4 C0 3 C1 3 C2 6
63COMPLEXITY
- Obviously,
- higher Cyclomatic Complexity
- means more Test Cases
64COMPLEXITY
- Obviously,
- higher Cyclomatic Complexity
- means more Test Cases
- Especially, C2 grows fast
65COMPLEXITY HOMEWORK
- start
- if C1 true
- then do P1
- if C2 true
- then do P3
- else do P4
- endif
- else do P2, P5
- endif
- if C3 true
- then do P6
- else
- if C4 true
- then do P7
- else do P8, P9
- endif
- do P10, P11
- endif
- end
- Draw a flowchart of
- this procedure (with the
- yes-branches to the left
- and the no-branches to
- the right)
66COMPLEXITY HOMEWORK
- Convert the flowchart to
- a diagram like that
- Control Flow Graph
- 3. Calculate the Complexity
- 4. Calculate C0
- 5. Calculate C1
- 6. Calculate C2
67Dr. Wolfgang J. Schneider - Start
DR. WOLFGANG J. SCHNEIDER GMBH International
Information Technology Consultants
Professional Testing Solutions Telecommunications
and Utility Billing Systems Euro Preparation for
Companies in New EU Member Countries EDIFACT
DATANORM ELDANORM ETIM Interfaces Data
Exchange with Banks and Credit Card
Companies Total Quality Management Good
Manufacturing Practices IT Service Management -
IT Infrastructure Library (ITIL) Knowledge
Management Solutions IT Fitness for GAAP IAS
FASB Balanced Scorecard
www.drschneider.at
Take Advantage of 30 Years of IT Experience !