Introduction to Software Testing
Chapter 2.1, 2.2
Overview Graph Coverage Criteria
www.introsoftwaretesting.com
Introduction to Software Testing
(Ch 2), www.introsoftwaretesting.com
2
Ch. 2 : Graph Coverage
Four Structures for
Four Structures for
Modeling Software
Modeling Software
Graphs
Graphs
Logic
Logic
Input Space
Input Space
Syntax
Use cases
Specs
Design
Source
Applied
to
DNF
Specs
Specs
FSMs
Source
Source
Applied to
Input
Input
Models
Models
Integ
Source
Applied
to
Introduction to Software Testing
(Ch 2), www.introsoftwaretesting.com
3
Covering Graphs
(2.1)
•
Graphs are the most commonly used structure for testing
•
Graphs can come from many sources
–
Control flow graphs
–
Design structure
–
FSMs and statecharts
–
Use cases
•
Tests usually are intended to “cover” the graph in some way
Introduction to Software Testing
(Ch 2), www.introsoftwaretesting.com
4
Definition of a Graph
•
A set
N
of nodes
,
N
is not empty
•
A set
N
0
of initial nodes
,
N
0
is not empty
•
A set
N
f
of final nodes
,
N
f
is not empty
•
A set
E
of edges
, each edge from one node to another
–
(
n
i
,
n
j
),
i
is predecessor,
j
is successor
Introduction to Software Testing
(Ch 2), www.introsoftwaretesting.com
5
Three Example Graphs
0
2
1
3
N
0
= { 0 }
N
f
= { 3 }
0
2
1
3
N
0
= { }
N
f
= { 3 }
9
0
4
3
7
1
5
8
2
6
N
0
= { 0, 1, 2 }
N
f
= { 7, 8, 9 }
Not a
Not a
valid
graph
Introduction to Software Testing
(Ch 2), www.introsoftwaretesting.com
6
Paths in Graphs
•
Path
: A sequence of nodes – [n
1
, n
2
, …, n
M
]
–
Each pair of nodes is an edge
•
Length
: The number of edges
–
A single node is a path of length 0
•
Subpath
: A subsequence of nodes in
p
is a subpath of
p
•
Reach
(
n
) : Subgraph that can be reached from
n
9
7
8
0
1
2
4
3
5
6
Paths
[ 0, 3, 7 ]
[ 1, 4, 8, 5, 1 ]
[ 2, 6, 9 ]
Reach (0) = { 0, 3, 4,
7, 8, 5, 1, 9 }
Reach ({0, 2}) = G
Reach([2,6]) = {2, 6,
9}