Control-Flow Testing
structural testing strategy that uses the program’s control flow as a model
Techniques
based on selecting a set of criteria throught the program
Idea
to pick enough test cases to assure that every source statement is executed as least once
Control-Flow Testing (Outline)
Control Flow Graphs
Statements Coverage
Decision Coverage
Path Coverage
Control Flowgraphs
Graphical representation of a program’s control structure
Three Primitivs of Flowgraphs
Decision: programs point at which control can diverge (e.g. if and case statements)
Process block: sequence of program statement uninterrupted by either decisions or junctions (i.e. straigt line code). it has one entry and one exit.
Junction: programm point where control flow can merge (e.g. end if, end loop)
Objective of path testing
ensure that the set of test cases is such that each path through the program is executed at least once
even small routine can have a large number of paths.
Limitations of Control-flow Testing
Interface mismathces and mistakes are not caught
Not all initialization mistakes are caught by control-flow testing
Specification mistakes are not caught
Data-flow testing
Why are test cases created
To pick enough paths to assure that every data object has been initialized prior to its use and that all defined objects have been used at least once
What does it use
Control flow graph to find data flow anomalies which are detected based on teh associations between definitions, initializations, and use of variables
Varaible lifecycle
d: defined, created and initialized
u: used
k: killes (destroyed, released)
Simple Path Segment
path segment in which at most one node is visited twice
E.g.,(7,4,5,6,7) is simple.
Therefore, a simple path may or may not be loop-free.
Loop-free Path Segemnt
path segment for which every node is visited at most most
E.g.,(4,5,6,7,8,10) is loop-free
Path (10,11,4,5,6,7,8,10,11,12) is not loop-free because node 10 and 11 are visited twice
definition clear path
All du-paths Strategy
One of the strngest data-flow testing strategies
requires that every du path from every definition of every varaible to every use of that definition be exercised under some test
Def-use Association
tripte (x,d,u), where
x is variable
d is note containing definition of x
u either statement or predicate node containing use of x
and sub path in flow graph from d tu u with no other definition of x between d and u
Last changed2 years ago