graph coverage (1)
DESCRIPTION
Graph Coverage (1). Reading Assignment. P. Ammann and J. Offutt “Introduction to Software Testing” Section 2.1. Outline. Covering Graphs Definition of a Graph Paths in Graph. Covering Graphs. Graphs are the most commonly used structure for testing Graphs can come from many sources - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/1.jpg)
1
Graph Coverage (1)Graph Coverage (1)
![Page 2: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/2.jpg)
Reading AssignmentReading AssignmentP. Ammann and J. Offutt
“Introduction to Software Testing”◦Section 2.1
2
![Page 3: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/3.jpg)
3
OutlineOutlineCovering Graphs
◦Definition of a Graph◦Paths in Graph
![Page 4: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/4.jpg)
4
Covering GraphsCovering GraphsGraphs are the most commonly
used structure for testingGraphs 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.
![Page 5: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/5.jpg)
5
Definition of a GraphDefinition of a GraphA set N of nodes, N is not empty
A set N0 of initial nodes, N0 is not empty
A set Nf of final nodes, Nf is not empty
A set E of edges, each edge from one node to another◦ ( ni , nj ), ni is predecessor, nj is successor◦ Initial nodes appear in edges with no predecessor◦ Final nodes are denoted with heavy borders
![Page 6: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/6.jpg)
6
Three Example GraphsThree Example Graphs0
21
3
N0 = { 0 }
Nf = { 3 }
0
21
3
N0 = { }
Nf = { 3 }
9
0
43
7
1
5
8
2
6
N0 = { 0, 1, 2 }
Nf = { 7, 8, 9 }
Not aNot avalidvalidgraphgraph
Sometimes graphs are restricted to those having oneinitial node and one final node. (how?)
![Page 7: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/7.jpg)
7
Paths in GraphsPaths in Graphs
Path : A sequence of nodes – [n1, n2, …, nM]◦ 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 pReach (n) : Subgraph that can be reached from n
![Page 8: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/8.jpg)
8
Paths in GraphsPaths in Graphs
97 8
0 1 2
43 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}
![Page 9: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/9.jpg)
9
Test Paths and SESEsTest 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
![Page 10: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/10.jpg)
10
Test Paths and SESEsTest Paths and SESEsSESE 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
0
2
1
63
5
4
Double-diamond graphFour test paths[ 0, 1, 3, 4, 6 ][ 0, 1, 3, 5, 6 ][ 0, 2, 3, 4, 6 ][ 0, 2, 3, 5, 6 ]
![Page 11: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/11.jpg)
11
Visiting and TouringVisiting 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 pTour : A test path p tours subpath q if q is a subpath of p
Path [ 0, 1, 3, 4, 6 ]
Visits nodes 0, 1, 3, 4, 6
Visits edges (0, 1), (1, 3), (3, 4), (4, 6)
Tours subpaths (0, 1, 3), (1, 3, 4), (3, 4, 6), (0, 1, 3, 4), (1, 3, 4, 6)
![Page 12: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/12.jpg)
12
Tests and Test PathsTests and Test Paths
path (t) : The test path executed by test tpath (T) : The set of test paths executed by the set
of tests TEach test executes one and only one test pathA 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
![Page 13: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/13.jpg)
13
Tests and Test PathsTests and Test Pathstest 1
test 2
test 3
many-to-one
test 1
test 2
test 3
many-to-manyTest Path 1
Test Path 2
Test Path 3
Non-deterministic software – a test can execute different test paths
Test Path
Deterministic software – a test always executes the same test path
![Page 14: Graph Coverage (1)](https://reader036.vdocuments.us/reader036/viewer/2022070403/56813956550346895da0f5c0/html5/thumbnails/14.jpg)
14
Key PointsKey PointsGraphs are the most commonly
used structure for testingGraphs are used in Testing
◦Developing a model of the software as a graph
◦Requiring test cases to visit or tour specific sets of nodes, edges or sub-paths.