0% found this document useful (0 votes)
3 views19 pages

Lecture 11 Part 2

The document discusses data flow testing techniques in software quality engineering, focusing on how data values flow through program units and the importance of verifying their correctness. It outlines two types of data flow testing: static and dynamic, and describes various anomalies that can occur with variable usage. Additionally, it highlights the advantages and disadvantages of data flow testing, emphasizing its role in identifying issues related to variable definitions and usages.

Uploaded by

eshaasif005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views19 pages

Lecture 11 Part 2

The document discusses data flow testing techniques in software quality engineering, focusing on how data values flow through program units and the importance of verifying their correctness. It outlines two types of data flow testing: static and dynamic, and describes various anomalies that can occur with variable usage. Additionally, it highlights the advantages and disadvantages of data flow testing, emphasizing its role in identifying issues related to variable definitions and usages.

Uploaded by

eshaasif005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Software Quality Engineering

White Box Testing Techniques- Data flow Testing


Instructor: Shumaila Iqbal
The General Idea

• A program unit accepts inputs, performs computations, assigns new values to variables, and returns
results.
• One can visualize of “flow” of data values from one statement to another.
• A data value produced in one statement is expected to be used later.
• Example
• Obtain a file pointer ……. use it later.
• If the later use is never verified, we do not know if the earlier assignment is acceptable.
• Two motivations of data flow testing
• The memory location for a variable is accessed in a “desirable” way.
• Verify the correctness of data values “defined” (i.e. generated) – observe that all the
“uses” of the value produce the desired results.
• Idea: A programmer can perform a number of tests on data values.
• These tests are collectively known as data flow testing.
2
• Data flow testing can be performed at two
conceptual levels.
• Static data flow testing
• Dynamic data flow testing
• Static data flow testing
• Identify potential defects, commonly
known as data flow anomaly.
The General • Analyze source code.
Idea • Do not execute code.
• Dynamic data flow testing
• Involves actual program execution.
• Bears similarity with control flow
testing.
• Identify paths to execute them.
• Paths are identified based on data
flow testing criteria.

3
• Anomaly: It is an abnormal way of doing
something.
• Example 1: The second definition of x
overrides the first.
• x = f1(y);
Data Flow • x = f2(z);

Anomaly • Three types of abnormal situations with


using variable.
• Type 1: Defined and then defined
again
• Type 2: Undefined but referenced
• Type 3: Defined but not referenced

4
• Type 1: Defined and then defined again (Example 1 above)
• Interpretations of Example 1
• The first statement is redundant.
• The first statement has a fault -- the intended one
might be: w = f1(y).
• The second statement has a fault – the intended
one might be: v = f2(z).
• Note: It is for the programmer to make the desired
interpretation.
Data Flow • Type 2: Undefined but referenced
Anomaly • Example: x = x – y – w; /* w has not been defined by the
programmer. */
• Two interpretations
• The programmer made a mistake in using w.
• The programmer wants to use the compiler
assigned value of w.
• Type 3: Defined but not referenced
• Example: Consider x = f(x, y). If x is not used
subsequently, we have a Type 3 anomaly.

5
• A programmer
6

manipulates/uses variables
in several ways.
• Initialization, assignment,
Overview of Dynamic Data Flow

using in a computation, using


in a condition
• Motivation for data flow
testing?
• One should not feel
confident that a variable has
been assigned the correct
value, if no test causes the
execution of a path from the
point of assignment to a
point where the value is
used.
• Note
• Assignment of correct value
means whether or not a value
has been correctly generated.
• Use of a variable means
• If new values of the same
variable or other variables
are generated.
• If the variable is used in a
conditional statement to
Testing
alter the flow of control.
• The above motivation
indicates that certain kinds
of paths are executed in
data flow testing.
• Occurrences of variables
7

• Definition: A variable gets a


new value.
• i = x; /* The variable i
gets a new value. */
• Use: This occurs when the
value is fetched from the
memory location of the
variable. There are two
forms of uses of a variable.
• Computation use (c-use)
• Example: x = 2*y; /* y
has been used to
compute a value of x.
*/
• Predicate use (p-use)
• Example: if (y > 100)
{ …} /* y has been
Data Flow Graph

used in a condition. */
• A data flow graph is a
8

directed graph constructed


as follows.
• A sequence of definitions
and c-uses is associated with
each node of the graph.
• A set of p-uses is associated
with each edge of the graph.
• The entry node has a
definition of each edge
parameter and each
nonlocal variable used in the
program.
• The exit node has an
undefinition of each local
variable.
Data Flow Graph
Data Flow Testing
Data Flow Testing
Data Flow Testing
Data Flow Testing
Data Flow Testing
Data Flow Testing
CFG ? VERIABLE DEFINED USED AT Draw
AT NODE NODE path
from def-
use

s
i
n
Data Flow Testing
• Advantages
• 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
• Time consuming and costly process
• Requires knowledge of programming languages
Practice
Solution
Practice Question
1. #include <iostream>
2. using namespace std;
3. int main() {
4. int n, reversed_number = 0, remainder,r;
5. cout << "Enter an integer: ";
6. cin >> n;
7. while(n != 0) {
8. remainder = n % 10;
9. reversed_number = reversed_number * 10 + remainder;
10. n /= 10;
11. }
12. cout << "Reversed Number = " << reversed_number;
13. return 0;
14.}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy