Data Flow Testing

Learn via video courses
Topics Covered

Overview

Data flow testing is a white box testing technique where the module is tested on the basis that the value of the variable passing is correct. Control flow graphs are used for the same. Flow testing is an excellent approach for integration testing.

What is Data Flow Testing?

Data flow testing is a white box testing type concerned with the flow of variables and not the module's flow. It follows where the variable is referenced. Data flow testing makes use of control flow graphs and associations.

The below example will look at both techniques.

Example

Control Flow Graph of the Above Example

Control flow graphs are used to represent the code graphically. This representation helps depict the code flow of variables to help data flow testing.

Control flow Graph

Types of Data Flow Testing

1. Static Data Flow Testing

Declaring the variables, using the variables, and finding the values all happen without the code execution is static data flow testing. Control flow graphs are used for the same.

2. Dynamic Data Flow Testing

The variables and their value are examined with the code execution in dynamic data flow testing. The changes in the variable and their references are observed with the requirement that the code must be executed.

Associations

Here associations are made between, where the variable is defined and used. The format of the association is as follows: (line variable declared, line variable used, variable name).

  1. int(x)

  2. if(x%2==0)

  3. x=x+10

  4. else

  5. x=x+5

Associations of the above code are as follows:

(1,(2,t),x) for the true condition in line 2 (1,(2,f),x) for the false condition in line 2 (1,3,x) for the x being used in line 3 (1,5,x) for the x being used in line 5

There are two types of uses of variables based on how they are being used in the code.

Predicate use: This value decides the flow of the code, as in line 2 is called p-use. Computational use: The variable's value is used by another variable, so if we have z=x in line 6. That would be a c-use.

Advantages of Data Flow Testing

  1. Data flow testing helps to redefine the flow of code.
  2. It helps to identify the excess code if it exists.
  3. It helps to identify computational variables.
  4. It tests the code without executing it.

Disadvantages of Data Flow Testing

  1. Since it is white box testing, coding knowledge is required.
  2. It is a time-consuming testing process.
  3. It requires a good amount of manual testing.
  4. It is a slow process as a lot of manual intervention is required.

Data Flow Testing Coverage

  1. All definition coverage: It covers all the sub-paths from each definition.
  2. All definition-c use coverage: It covers all the computation use sub-paths from each definition
  3. All definition-p use coverage: It covers all the predicate use sub-paths from each definition
  4. All-use coverage: It covers all the c-use and p-use sub-paths from each definition.
  5. All definition use coverage: It covers all the sub-paths from definition to their respective use.

Data Flow Testing Strategies

Test case selection criteria are as follows

  1. All-defs: All the sub-paths that include c-use and p-use. Suppose there is a variable x and node i to select all edges.
  2. All c-uses: There is global node i to all the sub-paths to node j. Select all the sub-paths which are c-use.
  3. All p-uses: There is global node i to all the sub-paths to node j. Select all the sub-paths which directly use variable x.
  4. Some c-uses: From the global declaration of variable x with node i, choose selectively sub-paths node j, which affects the module.
  5. Some p-uses: From the global declaration of variable x with node i. Choose selectively sub-paths node j directly affecting the value of a variable.

Data Flow Testing Applications

  1. Noticing the change and updation of a variable make the module more bug-free than merely doing branch testing.
  2. Debuggers are an excellent tool to track data changes in a variable.
  3. Data flow testing tools are integrable into the compilers helping in unit testing.

Conclusion

  1. Data flow testing is a white box testing type where the module is tested based on changes recorded by the variable.
  2. Data flow testing can be done both statically and dynamically.
  3. Control flow graphs and associations are excellent data flow testing techniques.
  4. Data flow testing tools are now integrated with the compilers directly.

See More