Unit2_ST
Unit2_ST
• If x was used before it was initialized, this would be a data flow error.
• Conclusion
• Data Flow Testing is a powerful technique to analyze how data moves
within a program, ensuring proper variable usage and eliminating bugs
caused by incorrect data handling. It is especially useful for critical
applications like banking, healthcare, and embedded systems.
• Commission Problem Using Define-Use (DU) Testing
• Commission Problem Statement
• A company calculates the sales commission for its employees based on the
following rules:
• If sales amount is less than $1000, commission is 5%.
• If sales amount is between $1000 and $5000, commission is 10%.
• If sales amount is greater than $5000, commission is 20%.
Advantages of Data Flow Testing
• 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
• Slice-Based Testing in Software Testing
• What is Slice-Based Testing?
• Slice-Based Testing is a white-box testing technique that focuses on
analyzing program slices to detect errors. A program slice is a subset of the
program that affects the value of a particular variable at a specific point in
execution.
• Example: Slice-Based Testing in a Commission Calculation Program
Control Flow Testing
• Control flow testing is a testing technique that comes
under white box testing.
• The aim of this technique is to determine the execution
order of statements or instructions of the program
through a control structure.
• Control Flow Graph is formed from the node, edge,
decision node, junction node to specify all possible
execution path.
Notations used for Control Flow
Graph
• Nodes in the control flow graph are used to create a
path of procedures. Basically, it represents the
sequence of procedures which procedure is next to
come so, the tester can determine the sequence of
occurrence of procedures.
• Edge in control flow graph is used to link the direction
of nodes.
• Decision node in the control flow graph is used to
decide next node of procedure as per the value.
• Junction node in control flow graph is the point where
at least three links meet.
Example
Slice-based testing
• Slicing or program slicing is a technique used in software
testing that takes a slice or a group of program statements
in the program for testing particular test conditions or cases
that may affect a value at a particular point of interest.
• It can also be used to debug to find the bugs more easily and quickly.
• Slicing techniques were originally defined by Mark Weiser and they were
only static at that time.
• Afterward, Bogdan Korel and Janusz Laski introduced dynamic slicing, which
can work for a particular execution of the program.
Types
• Static Slicing
• A static slice of a program contains all statements that may impact the value
of a variable at any point for any arbitrary execution of the program.
• Static slices are generally larger.
• It considers every possible execution of the program.
• Dynamic Slicing
• A dynamic slice of a program contains all the statements that actually impact
the value of a variable at any point for a particular execution of the program.
• Dynamic slices are mostly smaller.
• Considers only a particular execution of the program.
Example
Example
Program Slicing Tools
Test method pendulum
Effort and
efficacy of
unit test
methods