Module_4
Module_4
• In the path testing method, the control flow graph of a program is designed to find a set
of linearly independent paths of execution.
• It gives complete branch coverage but achieves that without covering all possible paths
of the control flow graph.
• Control Flow Graph (CFG) - The Program is converted into Flow graphs by
representing the code into nodes, regions and edges.
• Decision to Decision path (D-D) - The CFG can be broken into various
Decision to Decision paths and then collapsed into individual nodes.
• If i and j are nodes in the program graph, there is an edge from node i to node j iff
the statement (fragment) corresponding to node j can be executed immediately after
the statement (fragment) corresponding to node i.
• The groups of statements that make up a node in the Program Graph are called a
basic block.
• Decision coverage is good for exercising faults in the way a computation has
been decomposed into cases.
• A test suite T for a program P covers all C1P iff for each atomic condition in P, it
has at least two test cases in T: one forcing P to have a true out come and the
other one forcing P to have a false outcome.
Loop Coverage - C2:
• Test cases that exercise the two possible outcomes of the decision of a loop condition,
that is one to traverse the loop and the other to exit (or not enter) the loop.
• An extension would be to consider a modified boundary value analysis approach where
the loop index is given a minimum, minimum +, a nominal, a maximum-, and a
maximum value or even robustness testing.
• Once a loop is tested, then the tester can collapse it into a single node to simplify the
graph for the next loop tests. In the case of nested loops, we start with the innermost
loop and proceed outward
Dependent DD-Path Pairs Coverage - Cd
• two DD-Paths are said to be dependent iff there is a define/reference relationship
between these DD-Paths, in which a variable is defined (receives a value) in one
DD-Path and is referenced in the other.
• In Cd testing we are interested on covering all edges of the DD-Path graph and
all dependent DD-Path pairs.
Multiple (Compound) Condition Coverage – CMCC:
• CMCC, A more complete extension that includes both the basic condition and
branch adequacy criteria
• CMCC requires a test case T for each possible evaluation of compound
conditions.
• For N basic conditions, we need 2 N combinations of test cases are required.
• Short-circuit evaluation is effective in reducing the above number to a more
manageable number.
• For a compound predicate P1 (A or B), CMCC requires that each possible
combination of inputs be tested for each decision. Ex: if (A or B) requires, A =
True/False , B = True/False ( 4 Combinations of test cases)
Statistically Significant Path Coverage Testing –Cstat:
• The goal of statistically significant coverage is to develop methods for software
testing based on statistical methods, such as Multivariable Testing, Design of
Experiments, and Markov Chain usage models, and to develop methods for
software testing based on statistical measures and confidence levels.
code.
– a program can be analyzed in terms of
• how the variables are affected,
• assigned and
The following definitions refer to a program P that has a program graph G(P), and a set
of program variables V.
• Nodes correspond to program statements
• Edges correspond to the flow of information
• Program Graph G(P) with respect to program(P) has,
Single entry and single exit node
Number of edges from node to itself
Set of program variables: V
Set of all paths in P: PATHS(P)
Definition
• Node n ∈ G (P) is a defining node of the variable v ∈ V, written as DEF (v, n), iff
the value of the variable v is defined at the statement fragment corresponding to
node n.
Ex: Input (x)
Ex: x = 20
Definition
• Node n ∈ G (P) is a usage node of the variable v ∈ V, written as USE (v, n), iff the
value of the variable v is used at the statement fragment corresponding to node n.
Define/use of variables of the above example:
1. read x, y;
2. if(x>y)
3. a = x+1
else
4. a = y-1
5. print a;
• Definition-use path (du-path): A definition-use path with respect to a variable v
(denoted du-path) is a path in PATHS(P) such that, for some v ∈ V, there are
define and usage nodes DEF(v, m) and USE(v, n), where m and n are the initial
and final nodes of the path.
• The idea of slices is to separate a program into components that have some useful
meaning.
• Slice captures the execution time behavior of a program with respect to the
variable(s) in the slice.
Example:
Lattice
• A lattice in slice-based testing refers to the structure used to represent the
dependencies between different parts of the system, such as modules,
components, or functions.
• The lattice helps in identifying and selecting appropriate slices for testing, based
on the dependencies between different parts of the system.
• Consider a software system that consists of three modules: A, B, and C. Module
A depends on module B, and module B depends on module C. The dependencies
can be represented as a lattice, where module C is at the bottom, module B is in
the middle, and module A is at the top:
A
/\
B .
/\
C .