Structural Testing: Introduction - General Concepts Flow Graph Testing Data Flow Testing
Structural Testing: Introduction - General Concepts Flow Graph Testing Data Flow Testing
Structural Testing
Introduction – General Concepts
Flow Graph Testing
Data Flow Testing
Definitions
Some Basic Data Flow Analysis Algorithms
Define/use Testing
Slice Based Testing
Guidelines and Observations
Hybrid Methods
Retrospective on Structural Testing
1
Data Flow testing
• Dataflow testing refers to forms of structura
l testing that focus on the points at which va
riables receive values and the points at whic
h these values are used.
• Most programs deliver functionality in term
s of data.
• Variables that represent data some how rece
ive values,and these values are used to com
pute values for other variables.
2
• Early dataflow analyzers often centered on
a set of faults that are now known as define/
reference anomalies:
• A variable that is defined but never used(ref
erenced).
• A variable that is used before it is defined.
• A variable that is defined twice before it is
used.
3
Data Flow Testing – Basic Idea
• Data-flow testing involves selecting entry/exit paths with t
he objective of covering certain data definition and use patt
erns, commonly known as data-flow criteria
4
Some Definitions
5
2.Node n in the CFG of program 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.
6
Some Definitions (2)
• A usage node USE(v, n), is a predicate use (denote
d as P-use) iff the statement n is a predicate statem
ent, otherwise USE(v, n) is a computation use or C
-use
7
Some Definitions (3)
• A definition-use (sub)path with respect to a variable v (de
noted as du-path) is a (sub)path in PATHS(P), where PAT
HS(P) is the set of all possible paths in the CFG of progra
m P, such that, for some v in V, there are define and usage
nodes DEF(v, m) and USE(v, n) such that m, and n are the i
nitial and final nodes in the path respectively.
8
9
10
11
12
• Du-paths for Stocks
• First, let us look at a simple path: the du-path for t
he variable stocks. We have DEF(stocks, 15) and
• USE(stocks, 17), so the path <15, 17> is a du-path
with respect to stocks. No other defining nodes are
used for stocks; therefore, this path is also definiti
on clear.
13
• Du-paths for Locks
• Two defining and two usage nodes make the locks variable
more interesting: we have DEF(locks,
• 13), DEF(locks, 19), USE(locks, 14), and USE(locks, 16).
These yield four du-paths; they are
• shown in Figure 9.3.
• p1 = <13, 14>
• p2 = <13, 14, 15, 16>
• p3 = <19, 20, 14>
• p4 = <19, 20, 14, 15, 16>
14
DU-Path Test Coverage Criteria
• The basic idea is to use def-use information as defi
ned in the previous slides and specific criteria in o
rder to obtain specific paths in the CFG graph. The
se paths will then help us define specific test cases
15
DU-Path Coverage Criteria (1)
• The set T satisfies the All-Defs criterion for a program P iff
for every variable v in V, T contains definition clear (sub)p
aths from every defining node of v to a use of v. Note: Rea
ching definitions set
• The set T satisfies the All-DU-Paths criterion for the program P iff for every v
ariable v in V, T contains definition-clear (sub)paths from every defining node
of v to every use of v, and to the successor node of each USE(v, n), and that th
ese paths are either single loop traversals or cycle free
17
18