Ch07!1!2 OverviewGraphCoverage
Ch07!1!2 OverviewGraphCoverage
Testing
(2nd edition)
Chapter 7.1, 7.2
http://www.cs.gmu.edu/~offutt/softw
aretest/
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), E = { (1,4), (1,5), (2,5), (3,6), E = { (1,2),
(1,3), (2,4), (3, 7), (4, 8), (5,8), (5,9), (1,3), (2,4),
Introduction(3,4) } Edition 2 (Ch 07) (6,2), (6,10), (7,10)
to Software Testing, (9,6)
© Ammann & Offutt } (3,4) } 5
Paths in Graphs
• Path : A sequence of nodes – [n , n , …, n ]
1 2 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
1 2 3
A Few Paths
[ 1, 4, 8 ]
4 5 6 7 [ 2, 5, 9, 6, 2 ]
[ 3, 7, 10 ]
8 9 10
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 6
Test Paths and SESEs
• Test Path : 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 tests
• SESE graphs : All test paths start at a single
node and end at another node
– Single-entry, single-exit
– N0 and Nf have exactly one node
Double-diamond
2 5 graph
Four test paths
1 4 7
[1, 2, 4, 5, 7]
3 6 [1, 2, 4, 6, 7]
[1, 3, 4, 5, 7]
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt
[1, 3, 4, 6, 7] 7
Visiting and Touring
• Visit : A test path p visits node n if n is in p
A test path p visits edge e if e is in p
• Tour : A test path p tours subpath q if q is a
subpath of p
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)
2 PPC Requirements
:TR = { [1,2,3],
3 [2,2] }
1
Prime Paths
2 [1, 2, 3, 4, 7]
[1, 2, 3, 5, 7] Execute
[1, 2, 3, 5, 6] loop 0 times
3 [1, 3, 4, 7]
[1, 3, 5, 7] Execute
4 5 [1, 3, 5, 6] loop once
[6, 5, 7]
6 [6, 5, 6] Execute loop
7 [5, 6, 5] more than once
1 2 5
1 2 3 5 6
3
Touring with 4
4
a detour
• Three criteria
– Use every def
– Get to every use
– Follow all du-paths
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 30
Data Flow Test Criteria
• First, we make sure every def reaches a use