White Box Testing
Test your code
   Home      DataFlowTesting
 

Data Flow Testing

Data flow testing is a technique used to detect improper use of data in a program. By looking data usage, risky areas of code can be found and more test cases can be applied.To test data flow we devise control flow graph. A data-flow graph (DFG) is a graph which represents data dependencies between a number of operations.
 
 

Data Flow Anomalies

Data flow anomalies represent the rules which help to detect improper use of data. The notation used to define these anomalies
 
  • d – defined, created, initialized
  • k – undefined, killed
  • u – used
                c – Computation use
 
                p – Predicate use
 
  • ~x - all prior actions are not of interest to x
  • x~ - all post actions are not of interest to x
 
Anomalies which shows normal use of data
 
~d        Defined first
 
du        define –> use
 
kd        kill –> define
 
ud        use –> define
 
uk        use –> kill
 
uu        use –> use
 
k~        kill last
 
u~        use last          
 
Anomalies which shows bug and should be avoided in the programs
 
~u        first use           Bug. Data is used without definition.
 
~k        first kill             Bug. Data is killed without defining it.
 
dd        define–define   Bug. Redefinition of data.
 
dk        define –> kill    Bug. Data is killed without using it.
 
kk         kill – kill           Bug. Destroying already killed data.
 
ku         kill – use         Bug. Data is used after destroying it.
 
d~        define last       Bug. Defining but not using it.
 
 
 
 
 
Following is the CFG of a program


In this example following anomalies found
 
Data
Path
Anomalies
cmp
=>1
~u
temp
=>0
~d
temp1
=>0=>10
dk
top
=>9=>11=>2=>4, =>11=>2=>10
ku, kk
bot
=>8=>11=>2=>4, =>11=>2=>10
ku, kk
temp2
=>10
~k
mid
=0=>5, =>11=>2=>4
dd, ku

 
 
 
Data Flow Testing Strategies

All Definitions: Test cases for each definition of each variable

All Predicate Uses: Test cases are generated so that there is at least one path of each variable definition to each P-use of variable.

All Computational Uses: Test cases are generated so that there is at least one path of each variable definition to each C- use of variable.

All P uses Some C uses: Test cases for every variable, there is a path from every definition to every p-use of that definition. If there is a definition with no p-use following it, then a c-use of the definition is considered

All C uses Some P uses: Test cases for every variable, there is a path from every definition to every c-use of that definition. If there is a definition with no c-use following it, then a p-use of the definition is considered

All uses: Test cases for every use of the variable, there is a path from the definition of that variable to the use.

All du paths: This is the strongest data flow testing strategy. Every du path from every definition of every variable to every use of that definition

 

 

External References