Ch07-1-2-overviewGraphCoverage-active
Ch07-1-2-overviewGraphCoverage-active
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 = { }
Write down Write down Write down
the Nfinitial
= { 4and } Nthe
f = initial
{ 8, 9, and10 } theNfinitial
= { 4and
}
final
E = nodes, { (1, 2), final (1,5),
E = { (1,4), nodes,(2,5), (3,6), final
E =nodes,
{ (1,2),
and
(1,3), the (2,4),edges (3, 7),and
(4,the
8), edges
(5,8), (5,9), and the (2,4),
(1,3), edges
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
Write
[ 1, 4, 8 ]
4 5 6 7 down
[three
2, 5, 9, 6, 2 ]
paths
[ 3, 7, 10in]
this graph
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,
Write down5, 7]
3 6 [1,the
all 2, 4,test
6, 7]
[1, 3, 4,in5,this
paths 7]
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt
[1, 3, 4, 6, 7]
graph 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
Test path [ 1, 2, 4, 5, 7 ]
Visits nodes1,?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]
2 PPC Requirements
:TR
? = { [1,2,3],
3 [2,2] }
1
Prime Paths
2 [1, 2, 3, 4, 7]
[1, 2, 3,down
Write 5, 7] Execute
[1, 9
all 2, prime
3, 5, 6] loop 0 times
3 [1, 3, 4, 7]
paths
[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