STM Path Testing
STM Path Testing
This unit gives an indepth overview of path testing and its applications.
At the end of this unit, the student will be able to:
PATH TESTING:
o Path Testing is the name given to a family of test techniques based
on judiciously selecting a set of test paths through the program.
o If the set of paths are properly chosen then we have achieved
some measure of test thoroughness. For example, pick enough
paths to assure that every source statement has been executed at
least once.
o Path testing techniques are the oldest of all structural test
techniques.
o Path testing is most applicable to new software for unit testing. It is
a structural technique.
o It requires complete knowledge of the program's structure.
o It is most often used by programmers to unit test their own code.
o The effectiveness of path testing rapidly deteriorates as the size of
the software aggregate under test increases.
THE BUG ASSUMPTION:
o The bug assumption for the path testing strategies is that
something has gone wrong with the software that makes it take a
different path than intended.
o As an example "GOTO X" where "GOTO Y" had been intended.
o Structured programming languages prevent many of the bugs
targeted by path testing: as a consequence the effectiveness for
path testing for these languages is reduced and for old code in
COBOL, ALP, FORTRAN and Basic, the path testing is
indespensable.
CONTROL FLOW GRAPHS:
o The control flow graph is a graphical representation of a program's
control structure. It uses the elements named process blocks,
decisions, and junctions.
o The flow graph is similar to the earlier flowchart, with which it is not
to be confused.
o Flow Graph Elements:A flow graph contains four different types of
elements. (1) Process Block (2) Decisions (3) Junctions (4) Case
Statements
1. Process Block:
A process block is a sequence of program
statements uninterrupted by either decisions
or junctions.
It is a sequence of statements such that if any
one of statement of the block is executed, then
all statement thereof are executed.
Formally, a process block is a piece of straight
line code of one statement or hundreds of
statements.
A process has one entry and one exit. It can
consists of a single statement or instruction, a
sequence of statements or instructions, a
single entry/exit subroutine, a macro or
function call, or a sequence of these.
2. Decisions:
A decision is a program point at which the
control flow can diverge.
Machine language conditional branch and
conditional skip instructions are examples of
decisions.
Most of the decisions are two-way but some
are three way branches in control flow.
3. Case Statements:
A case statement is a multi-way branch or
decisions.
Examples of case statement are a jump table
in assembly language, and the PASCAL case
statement.
From the point of view of test design, there are
no differences between Decisions and Case
Statements
4. Junctions:
A junction is a point in the program where the
control flow can merge.
Examples of junctions are: the target of a jump
or skip instruction in ALP, a label that is a
target of GOTO.
Figure 2.4: Control Flowgraph for
example in Figure 2.2
The hidden loop around label 100 is not revealed by tests based on
prescription 3 alone because no test forces the execution of
statement 100 and the following GOTO statement. Furthermore,
label 100 is not flagged by the compiler as an unreferenced label
and the subsequent GOTO does not refer to an undefined label.
A: X5 > 0 E: X6 < 0
B: X1 + 3X2 + 17 >= 0 B: X1 + 3X2 + 17 >= 0
C: X3 = 17 C: X3 = 17
D: X4 - X1 >= 14X2 D: X4 - X1 >= 14X2
Boolean algebra notation to denote the
boolean expression:
ABCD+EBCD=(A+E)BCD
PREDICATE COVERAGE:
Compound Predicate: Predicates of the
form A OR B, A AND B and more
complicated boolean expressions are
called as compound predicates.
Some times even a simple predicate
becomes compound after interpretation.
Example: the predicate if (x=17) whose
opposite branch is if x.NE.17 which is
equivalent to x>17 . Or. X<17.
Predicate coverage is being the achieving
of all possible combinations of truth values
corresponding to the selected path have
been explored under some test.
As achieving the desired direction at a
given decision could still hide bugs in the
associated predicates.
TESTING BLINDNESS:
Testing Blindness is a pathological
(harmful) situation in which the desired
path is achieved for the wrong reason.
There are three types of Testing Blindness:
Assignment Blindness:
1. Assignment blindness occurs when
the buggy predicate appears to work
correctly because the specific value
chosen for an assignment statement
works with both the correct and
incorrect predicate.
2. For Example:
Correct Buggy
X=7 X=7
........ ........
if Y > 0 then ... if X+Y > 0 then ...
Correct Buggy
if Y = 2 then if Y = 2 then
........ ........
if X+Y > 3 then ... if X > 1 then ...
Correct Buggy
X=A X=A
........ ........
if X-1 > 0 then ... if X+A-2 > 0 then ...
PATH SENSITIZING:
ADFGHIJKL+AEFGHIJKL+BCDFGHIJKL+BCEFGHIJ
KL
PATH INSTRUMENTATION:
4. PATH INSTRUMENTATION:
Path instrumentation is what we have to do
to confirm that the outcome was achieved
by the intended path.
Co-incidental Correctness: The
coincidental correctness stands for
achieving the desired outcome for wrong
reason.