SVV 07 Ch07!1!2-OverviewGraphCoverage v0
SVV 07 Ch07!1!2-OverviewGraphCoverage v0
Testing
(2nd edition)
Chapter 7.1, 7.2
http://www.cs.gmu.edu/~offutt/softwaretest/
Specs DNF
Not a
valid
graph
2 3 4 5 6 7 2 3
4 8 9 10 4
N0 = { 1} N0 = { 1, 2, 3 } N0 = { }
Nf = { 4 } Nf = { 8, 9, 10 } Nf = { 4 }
E = { (1,2), (1,3), E = { (1,4), (1,5), (2,5), (3,6), (3, 7), (4, E = { (1,2), (1,3),
(2,4), (3,4) } 8), (5,8), (5,9), (6,2), (6,10), (7,10) (2,4), (3,4) }
Introduction to Software Testing, Edition 2 (Ch 07)
(9,6) }© Ammann & Offutt 6
Paths in Graphs
• Path: A sequence of nodes – [n1, n2, …, nM]
– Each pair of nodes is an edge
• Length (of a path): 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
• Cycle: A path that begins and ends in the same node.
8 9 10
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 7
Test Path
• A location in a graph (node or edge) can be reached from
another location if there is a sequence of edges from the
first location to the second
– Syntactic reach : A subpath exists in the graph
– Semantic reach : A test exists that can execute that subpath
• Test Path: A path p, possibly of length zero, that starts at
some node in N0 and ends at some node in Nf.
– A path that starts at an initial node and ends at a final node
• Test paths represent execution of test cases
– Some test paths can be executed by many tests.
– Some test paths cannot be executed by any test.
Test Path [ 1, 2, 4, 5, 7 ]
Visits nodes 1, 2, 4, 5, 7
Visits edges (1, 2), (2, 4), (4, 5), (5, 7)
Tours subpaths [1, 2, 4], [2, 4, 5], [4, 5, 7], [1, 2, 4, 5],
[2, 4, 5, 7], [1, 2, 4, 5, 7]
(Also, each edge is technically a subpath)
many-to-many
test 1 Test Path 1
4 5
6
7
6 Len 4
7 [1, 2, 3, 4, 7] !
[1, 2, 3, 5, 7] ! Prime Paths
[1, 2, 3, 5, 6] !
! means path terminates
* means path cycles
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 25
Simple & Prime Path Example
Simple Paths
[1], [2], [3], [4],
[1,2], [1,3], [2,4], [3,4], [4,1],
[1,2,4], [1,3,4], [2,4,1], [3,4,1], [4,1,2], [4,1,3],
[1,2,4,1], [1,3,4,1], [2,4,1,2], [2,4,1,3], [3,4,1,2], [3,4,1,3], [4,1,2,4], [4,1,3,4]
Prime Paths
1
[1,2,4,1], [1,3,4,1],
2 3
[2,4,1,2], [2,4,1,3],
4 [3,4,1,2], [3,4,1,3],
[4,1,2,4], [4,1,3,4]
1 2 3 5 6
1 2 5
1 2 3 5 6
3
Touring with a 4
4
detour
Edge-Pair
Coverage
EPC
Complete Round
Trip Coverage
Edge CRTC
Coverage
EC
Simple Round
Trip Coverage
Node SRTC
Coverage
NC
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 34
Summary 7.1-7.2
• Graphs are a very powerful abstraction for designing tests