0% found this document useful (0 votes)
25 views

STM Unit1 Part2

This document discusses path testing techniques used to test software programs. It defines key terms like control flow graphs, path testing, and path coverage. A control flow graph visually represents a program's structure and flow. Path testing involves executing every path through a program from entry to exit. Achieving full path coverage is generally impossible. The document outlines other path testing criteria like statement coverage and branch coverage. It also discusses topics like loops, path predicates, path sensitization, and instrumentation methods used for path testing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

STM Unit1 Part2

This document discusses path testing techniques used to test software programs. It defines key terms like control flow graphs, path testing, and path coverage. A control flow graph visually represents a program's structure and flow. Path testing involves executing every path through a program from entry to exit. Achieving full path coverage is generally impossible. The document outlines other path testing criteria like statement coverage and branch coverage. It also discusses topics like loops, path predicates, path sensitization, and instrumentation methods used for path testing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 32

UNIT – 1

part2

FLOW GRAPHS AND


PATH TESTING
Path Testing Basics
 Path Testing: Path Testing is a path wise
testing technique in the program.

 Path testing techniques are the oldest of all


structural test techniques.
Control Flow Graphs
 The control flow graph(or flow graph) is
a graphical representation of a
program.

 The flow graph is similar to the earlier


flowchart
Flow Graph Elements
 A flow graph contains four different
types of elements.
 Process Block

 Decisions

 Case Statements

 Junctions
Process Block
 process block is a piece of straight line code of one
statement or more number 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, or a sequence of
these.

entry PROCESS exit


Decisions
 A decision is a condition in program ,
based on this condition the statements
are executed.
 Most of the decisions are two-way but
some are three way branches in control
flow.
YES: then A is biggest
number

A>B
? NO: then B is biggest
number
Decisions
 Here the condition is A>B and the decision
is based on the condition .
 If A>B is true then “1.YES: then A is

biggest number “is executed otherwise,


“2.NO: then B is biggest number” is
executed.
1.YES: then A is
biggest number

A>B
?
2.NO: then B is biggest
number
Case Statements
 A case statement is a multi-way branch
or decisions.
 In case statement ,multiple cases are
there like case1,case2,…….case N.
 Based on ‘Case of’ value the
appropriate ‘case’ is executed.

1 Case 1
Case of
21 Case 2

N Case N
Junctions
 A junction is a point in the program
where the control flow can merge.

Junctions 1 2
Path Testing- paths, nodes and
links
 Path: a path through a program is a sequence of
instructions or statements that starts at an entry,
junction, or decision and ends at another, or possibly
the same junction, decision, or exit.
 A path may go through several junctions, processes,
or decisions, one or more times.
 Paths consists of segments.
 The segment is a link – a single process that lies
between two nodes.
 A path segment is succession of consecutive links
that belongs to some path.
 The length of path measured by the number of
links in it and not by the number of the instructions
or statements executed along the path.
 The name of a path is the name of the nodes along
the path.
Fundamental Path Selection
Criteria

 There are many paths between the entry and exit of a


typical routine.

 Defining complete testing:


 Exercise every path from entry to exit
 Exercise every statement or instruction at least once
 Exercise every branch and case statement, in each direction, at
least once
Path selection criteria - example
If ( X<0) go to statement number 200
X=X+A
200: X=X+A
300: CONTINUE

yes

X=X+A
X<0 200 X=X+A 300
? no
Path Testing Criteria
 Any testing strategy based on paths must at least
both exercise every instruction and take branches in
all directions.

 So we have explored three different testing criteria


or strategies out of a potentially infinite family of
strategies.
1. Path testing
2. Statement testing
3. Branch testing
Path Testing (Pinfinity)
 Path Testing: execute all possible control
flow paths through the program: typically,
this is restricted to all possible entry/exit
paths through the program.
 If we achieve this prescription, we are said to
have achieved 100% path coverage. This
is the strongest criterion in the path testing
strategy family: it is generally impossible to
achieve.
Statement Testing (P1)
 Execute all statements in the program at least
once under some test. If we do enough tests
to achieve this, we are said to have achieved
100% statement coverage.
 An alternate equivalent characterization is to
say that we have achieved 100% node
coverage. We denote this by C1.
 This is the weakest criterion in the family
Branch Testing ( P2)
 Execute enough tests to assure that every
branch alternative has been exercised at least
once under some test.
 If we do enough tests to achieve this
prescription, then we have achieved 100%
branch coverage.
 An alternative characterization is to say that we
have achieved 100% link coverage.
 We denote branch coverage by C2.
Loops
 LOOP is nothing but repeat the
statement execution until condition false.
 There are only three kinds of loops with
respect to path testing:
 Nested loops
 Concatenated loops
 Horrible loops
Nested Loops
Outer loop

Inner loop

1 2 3 4

The loop with in the loop is nothing but


NESTED LOOP.
In above diagram 1 to 4 is one loop called
outer loop , Similarly 2 to 3 is called inner
loop
Concatenated loops
 Concatenated loops are loops exists one
loop after another loop.
 In loop1 concatenated with loop2
 If the loops cannot be on the same path,
then they are not concatenated and can be
treated as individual loops.

loop1 loop2

1 2 3 4
Horrible loops
 A Horrible Loop is a combination of
nested loops and concatenatedloops.

1 2 3 4 5 6
Predicates, Predicate Expressions
Predicate: The logical function evaluated at a
decision : True or False.

Compound Predicate: Two or more predicates


combined with AND, OR etc.

Path Predicate :
• A predicate associated with a path is called path
predicate.
• Every path corresponds to a succession of
True/False values for the predicates traversed on
that path.
Path Predicate Expressions
 A path predicate expression is a set of
Boolean expressions
1. (A>B) AND (A>C)

2. (A>B) OR (A>C)

3. NOT(A>B)
 Boolean algebra notation to denote the
Boolean expression:
ABCD+EBCD=(A+E)BCD
Testing Blindness
 Testing Blindness is a pathological
situation in which the desired path is
achieved for the wrong reason.
 There are three types of Testing Blindness:
 Assignment Blindness
 Equality Blindness
 Self Blindness
Path Sensitizing
 The act of finding a set of solutions to the path predicate
expression is called PATH SENSITIZATION

 For any path in that set, interpret the predicates along the
path as needed to express them in terms of the input
vector.
 In general individual predicates are compound or may
become compound as a result of interpretation.
Path Sensitizing
 Trace the path through, multiplying the individual
compound predicates to achieve a Boolean expression
such as:
A(B+C)

 Multiply out the expression to achieve a sum of products


form:
AB+AC

 If you can find a solution, then the Path Is Achievable.

 If you cant find a solution to any of the sets of


inequalities, the path is Un Achievable.
Path Instrumentation
 Path instrumentation is what we
have to do to confirm that the outcome
was achieved by the intended path.
 Types of instrumentation methods are:
 An interpretive trace program
 Traversal marker or link marker
 The two link marker method
Interpretive trace program
 An Interpretive Trace Program is
one that executes every statement in
order and records the intermediate
values of all calculations, the statement
labels traversed etc.,
Traversal Marker Or Link Marker
 A simple and effective form of instrumentation is
called a Traversal Marker Or Link Marker.

 Give a Name to every link by a lower case letter.

 Instrument the links so that the link’s name is


recorded when the link is executed.
Example – Link Marker
[i] Input A,B,C ? [j] ? [k] ?
[l]

[m]
[n]

[o] ? [p] ? [q]

[r]

[s]
Two link marker method
 The solution to the problem of single
link marker method is to implement two
markers per link: one at the beginning
of each link and on at the end.
 The two link markers now specify the
path name and confirm both the
beginning and end of the link.
Example - Two link marker

[i] [j] ? [k] process A Process B [l]

[m] [n]

[o]

Process C [p] ? [q]


Process D [r]
Application of Path Testing
 Integration, coverage, and paths in
called components.
 New code
 Maintenance
 Re hosting

You might also like