whatsapp

What is Data Flow Testing? Application, Examples and Strategies

Process

Monday November 25, 2019

Data Flow Testing is a specific strategy of software testing that focuses on data variables and their values. It makes use of the control flow graph. When it comes to categorization Data flow testing will can be considered as a type of white box testing and structural types of testing. It keeps a check at the data receiving points by the variables and its usage points. It is done to cover the path testing and branch testing gap.

The process is conducted to detect the bugs because of the incorrect usage of data variables or data values. For e.g. Initialization of data variables in programming code, etc.

data flow testing

What is Data flow Testing?

  • The programmer can perform numerous tests on data values and variables. This type of testing is referred to as data flow testing.
  • It is performed at two abstract levels: static data flow testing and dynamic data flow testing.
  • The static data flow testing process involves analyzing the source code without executing it.
  • Static data flow testing exposes possible defects known as data flow anomaly.
  • Dynamic data flow identifies program paths from source code.

Let us understand this with the help of an example.

Data flow testing exampe

There are 8 statements in this code. In this code we cannot cover all 8 statements in a single path as if 2 is valid then 4, 5, 6, 7 are not traversed, and if 4 is valid then statement 2 and 3 will not be traversed.

Hence we will consider two paths so that we can cover all the statements.

x= 1

Path – 1, 2, 3, 8

Output = 2

If we consider x = 1, in step 1; x is assigned a value of 1 then we move to step 2 (since, x>0 we will move to statement 3 (a= x+1) and at end, it will go to statement 8 and print x =2.

For the second path, we assign x as 1

Set x= -1

Path = 1, 2, 4, 5, 6, 5, 6, 5, 7, 8

Output = 2

x  is set as 1 then it goes to step 1 to assign x as 1 and then moves to step 2 which is false as x is smaller than 0 (x>0 and here x=-1). It will then move to step 3 and then jump to step 4; as 4 is true (x<=0 and their x is less than 0) it will jump on 5 (x<1) which is true and it will move to step 6 (x=x+1) and here x is increased by 1.

So,

x=-1+1

x=0

x become 0 and it goes to step 5(x<1),as it is true it will jump to step

6 (x=x+1)

x=x+1

x= 0+1

x=1

x is now 1 and jump to step 5 (x<1) and now the condition is false and it will jump to step 7 (a=x+1) and set a=2 as x is 1. At the end the value of a is 2. And on step 8 we get the output as 2.

Steps of Data Flow Testing

  • creation of a data flow graph.
  • Selecting the testing criteria.
  • Classifying paths that satisfy the selection criteria in the data flow graph.
  • Develop path predicate expressions to derive test input.

The life cycle of data in programming code

  • Definition: it includes defining, creation and initialization of data variables and the allocation of the memory to its data object.
  • Usage: It refers to the user of the data variable in the code. Data can be used in two types as a predicate(P) or in the computational form(C).
  • Deletion: Deletion of the Memory allocated to the variables.

Types of Data Flow Testing

  • Static Data Flow Testing

No actual execution of the code is carried out in Static Data Flow testing. Generally, the definition, usage and kill pattern of the data variables is scrutinized through a control flow graph.

  • Dynamic Data Flow Testing

The code is executed to observe the transitional results. Dynamic data flow testing includes:

  • Identification of definition and usage of data variables.
  • Identifying viable paths between definition and usage pairs of data variables.
  • Designing & crafting test cases for these paths.

Advantages of Data Flow Testing

  • Variables used but never defined,
  • Variables defined but never used,
  • Variables defined multiple times before actually used,
  • DE allocating variables before using.

Data Flow Testing Limitations

  • Testers require good knowledge of programming.
  • Time-consuming
  • Costly process.

Data Flow Testing Coverage

  • All definition coverage: Covers “sub-paths” from each definition to some of their respective use.
  • All definition-C use coverage: “sub-paths” from each definition to all their respective C use.
  • All definition-P use coverage: “sub-paths” from each definition to all their respective P use.
  • All use coverage: Coverage of “sub-paths” from each definition to every respective use irrespective of types.
  • All definition use coverage: Coverage of “simple sub-paths” from each definition to every respective use.

Data Flow Testing Strategies

 

data flow testing strategies

Following are the test selection criteria

1. All-defs: For every variable x and node i in a way that x has a global declaration in  node I, pick a comprehensive path including the def-clear path from node i to

  • Edge (j,k) having a p-use of x or
  • Node j having a global c-use of x

2. All c-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including the def-clear path from node i to all nodes j having a global c-use of x in j.

3. All p-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including the def-clear path from node i to all edges (j,k) having p-use of x on edge (j,k).

4. All p-uses/Some c-uses: it is similar to all p-uses criterion except when variable x has no global p-use, it reduces to some c-uses criterion as given below

5. Some c-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including the def-clear path from node i to some nodes j having a global c-use of x in node j.

6. All c-uses/Some p-uses:it is similar to all c-uses criterion except when variable x has no global c-use, it reduces to some p-uses criterion as given below:

7. Some p-uses: For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including def-clear paths from node i to some edges (j,k) having a p-use of x on edge (j,k).

8. All uses:it is a combination of all p-uses criterion and all c-uses criterion.

9. All du-paths:For every variable x and node i in a way that x has a global declaration in node i, pick a comprehensive path including all du-paths from node i

  • To all nodes j having a global c-use of x in j and
  • To all edges (j,k) having a p-use of x on (j,k).

Data Flow Testing Applications

As per studies defects identified by executing 90% “data coverage” is twice as compared to bugs detected by 90% branch coverage.

The process flow testing is found effective, even when it is not supported by automation.

It requires extra record keeping; tracking the variables status. The computers help easy tracking of these variables and hence reducing the testing efforts considerably. Data flow testing tools can also be integrated into compilers.

Conclusion

Data is a very important part of software engineering. The testing performed on data and variables play an important role in software engineering.  Hence this is a very important part and should be properly carried out to ensure the best working of your product.

Mail

Hire

Cost Calc.

WhatsApp

Call Us