BASIS PATH TESTING. Path Testing Program graph is a directed graph in which – nodes are either...
-
Upload
hollie-greer -
Category
Documents
-
view
216 -
download
2
Transcript of BASIS PATH TESTING. Path Testing Program graph is a directed graph in which – nodes are either...
BASIS PATH TESTING
Path Testing• Program graph is a directed graph in which
– nodes are either entire statements or fragments of a statement,
– edges represent flow of control.
• The importance of the program graph is that program executions
correspond to paths from the source to the sink nodes.
DD-Paths
• The best known form of structural testing is based on a construct known as
a decision-to-decision path (DD-Path) [Miller 77].
• The name refers to a sequence of statements that, in Miller’s words, begins
with the “outway” of a decision statement and ends with the “inway” of
the next decision statement.
• There are no internal branches in such a sequence, so the corresponding
code is like a row of dominoes lined up so that when the first falls, all the
rest in the sequence fall.
• DD-Paths in terms of paths of nodes in a directed graph.
• We might call these paths chains, where a chain is a path in which the initial
and terminal nodes are distinct, and every interior node has indegree = 1
and outdegree = 1.
• A DD-Path is a chain in a program graph such that
– Case 1: it consists of a single node with indeg = 0,
– Case 2: it consists of a single node with outdeg = 0,
– Case 3: it consists of a single node with indeg ≥ 2 or outdeg ≥ 2,
– Case 4: it consists of a single node with indeg = 1 and outdeg = 1,
– Case 5: it is a maximal chain of length ≥ 1.
• DD-Path graph is the directed graph in which
– nodes are DD-Paths of its program graph, and
– edges represent control flow between successor DD-Paths.
• Cases 1 and 2 establish the unique source and sink nodes of the
program graph of a structured program as initial and final DD-Paths.
• Case 3 deals with complex nodes; it assures that no node is contained
in more than one DD-Path.
• Case 4 is needed for “short branches”; it also preserves the one
fragment, one DD-Path principle.
• Case 5 is the “normal case”, in which a DD-Path is a single entry, single
exit sequence of nodes (a chain).
– The “maximal” part of the case 5 definition is used to determine the final
node of a normal (non-trivial) chain.
DD-Path Graph for the Triangle Program
Program Graph of the Triangle Program
Basis Path Testing• Notion of a “basis” has attractive possibilities for structural testing.
• A basis in terms of a structure called a “vector space”, which is a set of
elements (called vectors) and which has operations that correspond to
multiplication and addition defined for the vectors.
• Basis path testing is a white-box testing technique first proposed by Tom
McCabe [MCC76].
• The basis path method enables the test case designer to derive a logical
complexity measure of a procedural design and use this measure as a
guide for defining a basis set of execution paths.
• Test cases derived to exercise the basis set are guaranteed to execute
every statement in the program at least one time during testing.
• Cyclomatic complexity is a software metric that provides a quantitative
measure of the logical complexity of a program.
• CC defines the number of independent paths in the basis set of a
program and
• Provides us with an upper bound for the number of tests that must be
conducted to ensure that all statements have been executed at least
once.
• An independent path is any path through the program that introduces
at least one new set of processing statements or a new condition.
Complexity is computed in one of three ways:
1. The number of regions of the flow graph correspond to the cyclomatic
complexity.
2. Cyclomatic complexity, V(G), for a flow graph, G, is defined as
V(G) = E - N + 2
where E is the number of flow graph edges, N is the number of flow graph
nodes.
3. Cyclomatic complexity, V(G), for a flow graph, G, is also defined as
V(G) = P + 1
where P is the number of predicate nodes contained in the flow graph G.
1. The flow graph has four regions.
2. V(G) = 11 edges - 9 nodes + 2 = 4.
3. V(G) = 3 predicate nodes + 1 = 4.
• The following are basis paths for Triangle pbm. DD-Path Graph for the
Triangle Program
• The problem here is that there are several inherent dependencies in
the triangle problem.
– One is that if three integers constitute sides of a triangle, they
must be one of the three possibilities: equilateral, isosceles, or
scalene.
– A second dependency is that the three possibilities are mutually
exclusive: if one is true, the other two must be false.
• We can identify several rules for the pbm:
– If node B is traversed, then we must traverse nodes D and E.
– If node C is traversed, then we must traverse nodes D and L.
– If node E is traversed, then we must traverse one of nodes F, H, and J.
– If node F is traversed, then we cannot traverse nodes H and J.
– If node H is traversed, then we cannot traverse nodes F and J.
– If node J is traversed, then we cannot traverse nodes F and I.
• The following feasible basis path set:
• The triangle problem is atypical in that there are no loops.
• The program has only 18 topologically possible paths, and of these,
only the four basis paths listed above are feasible.