Professional Documents
Culture Documents
Owolabi Legunsen
The following are modified versions of the publicly-available slides for Chapter 7
in the Ammann and Offutt Book, “Introduction to Software Testing”
(http://www.cs.gmu.edu/~offutt/softwaretest)
Graph Coverage
Four Structures for
Modeling Software
Specs DNF
• Not in CS 5154
– Applying graph coverage criteria to design, specs, and use cases
N0 = { 1 }
Is this a Yes
Nf = { 1 }
graph? 1
E={}
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 the Write down the Write down the
initialNand f = {final 4} N 8, final
f = {and
initial 9, 10 } initialNand 4}
f = {final
nodes,
E = {and (1,the2), nodes,
E = { (1,4), and the(2,5), (3,6),
(1,5), nodes,
E = and the
{ (1,2),
edges
(1,3), (2,4), (3, 7),edges
(4, 8), (5,8), (5,9), edges
(1,3), (2,4),
(3,4) }
Introduction to Software Testing, Edition 2 (Ch 07)
(6,2), (6,10), (7,10) (9,6) }
© Ammann & Offutt
(3,4) } 7
Paths in Graphs
• Path : A sequence, p, of nodes [n1, n2, …, nM] s.t. there is
an edge between each pair of nodes in p
• Length of a path : The number of edges in p
– 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 ]
Write down
4 5 6 7 [three
2, 5,paths
9, 6, in
2]
this graph
[ 3, 7, 10 ]
8 9 10
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 8
Test Paths and SESE graphs
• 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 graph
2 5 Four test paths
[1, 2, 4, 5, 7]
1 4 7
[1, 2,down
Write 4, 6, all
7]
3 6 [1,test
the 3, 4, 5, 7]in
paths
[1,graph
this 3, 4, 6, 7]
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 9
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 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]
many-to-many
test 1 Test Path 1
Node Coverage : ? TR = { 1, 2, 3 }
1 Test Path = [ 1, 2, 3 ]
EPC Requirements : ?
1 TR = { [1,2,3], [1,2,2], [2,2,3], [2,2,2] }
2 PPC Requirements : ?
TR = { [1,2,3], [2,2] }
3
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 a 4
4
detour
• The criteria omit nodes & edges that are not in round trips
X = 42
2 5 def (5) = { Z } Fill in
these
1 4 7 def (6) = { Z } sets
3 6 Uses: use (5) = { X }
Z = X-8 use (6) = { X }
• Three criteria
– Use every def
– Get to every use
– Follow all du-paths
[ 1, 2, 4, 6 ] [ 1, 3, 4, 5 ]
[ 1, 2, 4, 6 ]
[ 1, 3, 4, 6 ]
Prime Path
Coverage
PPC
All-DU-Paths
Coverage
ADUP Edge-Pair
Coverage
EPC
All-uses Complete Round
Coverage Trip Coverage
AUC Edge CRTC
Coverage
EC
All-defs Simple Round
Coverage Trip Coverage
ADC Node SRTC
Coverage
NC
Introduction to Software Testing, Edition 2 (Ch 07) © Ammann & Offutt 45
Summary
• Graphs are a very powerful abstraction for designing tests