Testing Methods_White Box Testing_3
Testing Methods_White Box Testing_3
METHODS
LECTURE 3 : WEEK 3
Credit : (3 + 0) / Week
Learning Outcome
2
exactly n times.
Try to design a test causing the loop body to be
V(G) = E – N + 2
where E is the number of flow graph edges and N is the number of flow
graph nodes.
Cyclomatic complexity, V(G), for a graph flow G is also defined as
V(G) = P + 1
Path 2: To find the next basis path, flip the first decision (only) in your baseline,
giving you FTT for your desired decision outcomes.
Path 3: You flip the second decision in your baseline path, giving you TFT for your
third basis path. In this case, the first baseline decision remains fixed with the true
outcome.
Path 4: Finally, you flip the third decision in your baseline path, giving you TTF for
your fourth basis path. In this case, the first baseline decision remains fixed with
the true outcome.
So, your four basis paths are TTT, FTT, TFT, and TTF.
Path Coverage Testing
Advantages
Covers all basic blocks (does all of basic block
testing)
Covers all conditions (does all of decision/condition
testing)
Does all of both, but with fewer tests!
Automatable (in practice requires automation)
Disadvantages
Does not take data complexity into account at all
Path Coverage Testing Disadvantages
Example: These
fragments should
be tested the same
way, since they
actually implement
the same solution -
but the one on the
left gets five tests,
whereas the one
on the right gets
only one
White Box Data Coverage
Data Coverage Methods
Data coverage methods explicitly try to
cover the data aspects of the program
code, rather than the control aspects
In this course we will cover data flow
coverage including several different data
flow coverage test criteria.
(Won’t do these in detail, just overview)
White Box Data Coverage
Data Flow Coverage
Data flow coverage is concerned with variable definitions
and uses along execution paths
A variable is defined if it is assigned a new value during a
statement execution
A variable definition in one statement is alive in another if
there is a path between the two statements that does not redefine
the variable
There are two types of variable uses
A P-use of a variable is a predicate use (e.g. if statement)
A C-use of a variable is a computation use or any other use (e.g.
I/O statements)
Example: Definition, P-Use, C-Use
of Variables
Example: Definition, P-Use, C-Use of
Variables
Example: Definition Clear path
Example: Definition-C-use Association
Example: Definition-P-use Association
White Box Data Coverage
Data Flow Coverage
There are a variety of different testing strategies related
to data flow:
All-Uses coverage: test all uses of each definition
All-Defs coverage: test each definition at least once
All C-Uses/Some P-Uses coverage: test all computation uses. If
no computation uses for a given definition then test at least
one predicate use
All P-Uses/Some C-Uses coverage: test all predicate uses. If no
predicate uses for a given definition then test at least one
computation use
White Box Data Coverage
Data Flow Coverage
We have covered definitions of data, uses of data,
and testing strategies for data flow coverage.
System: Identify definitions (and uses) of variables
and testing strategy. design a set of test cases
that cover the testing strategy
Completion criterion: Depends on the test
strategy. For example, in All-Defs we are done
when we have a test case for each variable
Summary
Testing Methods: White Box Testing II
Code coverage methods:
Decision analysis methods
(decision, condition, loop coverage, path
coverage)
Data coverage methods:
data flow coverage
Assignment
36 END OF LECTURE