control flow testing
TRANSCRIPT
Control Flow Testing
Presented By
Hirra Sultan
Roll Number: 120101091
Enrollment number: 2012017740
Supervisor: Mr. Sudeep Varshney
Introduction
Control-flow testing is a structural testing strategy that uses the
program’s control flow as a model.
It is a testing technique that comes under white box testing.
The entire structure, design, and code of the software have to be studied
for this type of testing.
Often the testing method is used by developers themselves to test their
own code and design as they are very familiar with the code.
This method is implemented with the intention to test logic of the code
so that the required results or functionalities can be achieved.
Its applicability is mostly to relatively small programs or segments of
larger programs, thus it is mostly used for unit testing.
Outline Of Control Flow Testing
Process of control flow testing:
The basic idea behind Control Flow Testing is to select paths and
come up with the inputs (input values/test cases) to execute through
those paths. It includes the following 4 steps:
Step 1: From the source code a control flow graph(CFG) is
created either manually or automatically (using a software).
Step 2: A coverage target is defined over the CFG e.g., nodes,
paths, branches, edges etc.
Step 3: Test cases are created using CFG to cover the coverage
target.
Step 4: Execute the test cases.
Step 5: Analyze the results and determine whether the program
is error free or has some bugs.
Control Flow Graph
The control flow graph is a graphical representation of control
structure of a program. Following notations are used for a flow
graph:
Node: It represents one or more procedural statements.
Edges or links: They represent the flow of control in a program.
Decision node: A node with more than one arrow leaving is
called a decision node.
Junction node: A node with more than one arrow entering it is
called a junction.
Regions: Areas bounded by edges and nodes are called regions.
Cyclomatic Complexity
Cyclomatic complexity measures the number of independent
paths through a program's source code.
Cyclomatic complexity is computed using CFG.
The formula used for calculating Cyclomatic complexity is
M = E − N + 2P, E = edges, N = nodes,
P = components
Or M = D + 1, D = decision node
Or M = R + 1, R = enclosed regions
Paths
A path through a program is a sequence of statements that starts
at an entry, junction, or decision and ends at another (possible
the same), junction, decision, or exit.
A feasible path in CFG is one which can be verified by a set of
possible inputs.
Infeasible Path is such a path in CFG that cannot be verified by
any set of possible input values and most expensive activities of
software testing.
An independent path is any path through the graph that
introduces at least one new set of processing statements or new
conditions.
Path Selection Criteria
Statement Coverage: It is assumed that if all the statements of
the module are executed once, every bug will be notified.
Decision coverage: This criterion states that one must write
enough test cases such that each decision has a true and false
outcome at least once.
Condition coverage: In this case, one writes enough test cases
such that each condition in a decision takes on all possible
outcomes at least once.
Advantages
It catches 50% of all the bugs caught during unit testing. That
amounts to 33% of all the bugs caught in the program.
Experienced programmers can bypass drawing flow charts by
doing path selection on source code.
The flow charts can even be made by an automated program
(software) and is not necessarily drawn by hand.
Disadvantages
We’re unlikely to find spurious features that were included in the
software but were not in the requirements.
It's unlikely to find missing paths and features if the program
and the model on which the tests are based are done by the same
person.
Coincidental correctness, however improbably, defeats this
technique unless we can verify all intermediate calculations and
predicate values.