Data Flow Testing

Data Flow Testing is a type of structural testing. It is a method that is used to find the test paths of a program according to the locations of definitions and uses of variables in the program. It has nothing to do with data flow diagrams.
It is concerned with:

  • Statements where variables receive values,
  • Statements where these values are used or referenced.

To illustrate the approach of data flow testing, assume that each statement in the program assigned a unique statement number. For a statement number S-

DEF(S) = {X | statement S contains the definition of X}
USE(S) = {X | statement S contains the use of X} 

If a statement is a loop or if condition then its DEF set is empty and USE set is based on the condition of statement s.



Data Flow Testing uses the control flow graph to find the situations that can interrupt the flow of the program.
Reference or define anomalies in the flow of the data are detected at the time of associations between values and variables. These anomalies are:

  • A variable is defined but not used or referenced,
  • A variable is used but never defined,
  • A variable is defined twice before it is used

Advantages of Data Flow Testing:
Data Flow Testing is used to find the following issues-

  • To find a variable that is used but never defined,
  • To find a variable that is defined but never used,
  • To find a variable that is defined multiple times before it is use,
  • Deallocating a variable before it is used.

Disadvantages of Data Flow Testing

  • Time consuming and costly process
  • Requires knowledge of programming languages

Example:

1. read x, y;
2. if(x>y)
3. a = x+1
else
4. a = y-1
5. print a; 

Control flow graph of above example:

Define/use of variables of above example:

Variable Defined at node Used at node
x 1 2, 3
y 1 2, 4
a 3, 4 5



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.