You are on page 1of 16

Data Flow Testing

THE STRATEGIES Page 163 of the Boris Beizer text


Basics of strategies…
• Data flow testing strategies are structural strategies.
• Data flow strategies require data-flow link weights
(d,k,u,c,p).
• They are based on selecting test path segments (sub-
paths) that satisfy some characteristic of data flows
for all data objects.
• A strategy X is stronger than strategy Y if all test
cases produced under Y are included in those
produced under X.
• Conversely for weaker strategies.
Overview of the strategies considered:
• The structural test strategies that we will discuss in
the further slides are based on the program’s control
flow graph.
• The differences in these strategies are –
– the predicate uses and/or computational uses of variables
included in the test set
– All computational uses versus at least one computational
use
– Both computational and predicate versus either one or
the other
All – du paths (ADUP):
• This is the strongest data-flow testing strategy.
• A du-path from node i to k is a path segment such
that, if the last link has a computational use of X, then
the path is simple & definition clear.
• ADUP is a data-flow testing strategy that requires
every definition of every variable from every du path
to use every variable of that definition.
• ADUP becomes more complicated when a variable is
redefined in many places.
• This strategy considers one test at a time.
• ADUP requires the greatest number of paths.
All – du paths (ADUP cont…):
Example:
A, B
C
Begin 1 2 3 4 End

From the figure, we see that variables A and B are


defined on link (1,2). It is evident that any path taken
for the graph will traverse through (1,2) . Hence the
criterion for variables A & B as per ADUP is satisfied.
But we have a redefinition at link (3,4). Variable C
will not satisfy ADUP if only the path (1,3) is taken,
thus violating the ADUP definition.
ADUP becomes complicated when a variable is
redefined in many places.
All – Uses strategy (AU):
• Here, we step down from all paths to branch
coverage.
• AU is a strategy that requires every definition from at
least one path segment to use every variable that
can be reached by that definition.
C
Begin 1 2 3 4 5 End
X

If a variable X has a predicate use as shown above, the


sub-paths (2,3,4) and (2,4) would be included in
some tests. In AU strategy, we don’t have to use
both in the same path, meaning (4,5) can be reached
by either (2,3,4) or (2,4).
All – du paths (ADUP cont…):
Example:
A, B
C
Begin 1 2 3 4 End

From the figure, we see that variables A and B are


defined on link (1,2). It is evident that any path taken
for the graph will traverse through (1,2) . Hence the
criterion for variables A & B as per ADUP is satisfied.
But we have a redefinition at link (3,4). Variable C
will not satisfy ADUP if only the path (1,3) is taken,
thus violating the ADUP definition.
ADUP becomes complicated when a variable is
redefined in many places.
All–p–Uses/Some–c–Uses strategies
(APU+C):
• If a variable has a predicate use, then, there is no
need to select a computational use.
• The (APU+C) is a strategy requires that – for every
variable and its definition, include at least one
definition-free path from the definition to every
predicate use. If there are definitions of the variable
that are not covered by predicate use, then add
computational-use test cases as required, to cover
every definition.
All–p–Uses/Some–c–Uses strategies
(APU+C cont…):
Flow graph annotated for variable Z
d P cd cd cd P P
Begin 1 2 3 4 5 6 7 8 9 End
Z
• In the (APU + C) strategy, every definition of every
variable has a path to every P-use of that definition.
If there is no P-use of the definition, then a c-use is
considered.
• Links (1,2), (3,4), (4,5), (5,6) must be included in test cases
because they contain definitions for variable Z. The links
(2,3),(6,7),(8,9) must also be included in test cases
because they contain predicate uses of Z, which c-use
does not cover.
All–c–Uses/Some–p–Uses strategies
(ACU-P):
• In this testing strategy, we first need to ensure that every
definition has a computational use of that definition and if
any definition is not covered, predicate use cases are added
to ensure(make sure) that every definition is included in
some test case.

• Definition:
(ACU + P) is a testing strategy which requires that every
definition of every variable includes at least one path from
that definition to every computational use.
All–c–Uses/Some–p–Uses strategies
(ACU-P cont…): Flow graph annotated for variable
d cY c p
Begin 1 2 3 4 5
c p
Y
Z c
End 10 9 8 7 6
• As seen above, ACU coverage is achieved for Y by the path
(1,2,3,4,7,8,9,10). But several definitions of predicate uses are
not covered – path (4,5,6,7).
• In this testing strategy, every definition of every variable has a
path to every c-use of that definition. If there is no c-use of that
definition, the p-use of the definition is considered. Hence, the
(ACU+P) coverage of the path for Y should be (1,2,3,4,7,8,9,10).
All – Definitions strategy (AD):
• The AD strategy is weaker than both (ACU+P) and (APU+C)
strategies.
• Definition: AD is a testing strategy that requires every definition
of every variable to cover at least one use of that variable. The
use can be a computational use(c) or a predicate use(p).
• The path (1,2,3,4,5,6,7,8,9,10) satisfies the AD strategy for
variable Y. For the variable Z, any entry or exist
**Refer path satisfies
the earlier slide for fig.
the AD criterion. Therefore, we expect that the AD strategy is
weaker than both the (ACU+P) and (APU+C) strategies.
• Every definition has a path to at least one use of that definition.
All–Predicate–Uses Strategy:
• In this testing strategy, every definition of every
variable has a path to every P-use of that definition.
• If there is no P-use in the definition, then it is dropped
from the contention(argument).
• Definition: APU is a testing strategy derived from the
(APU+C) strategy. But here, we do not include a c-use
for the variable if there are no p-uses for the variable
following each definition.
APU is therefore weaker than (APU+C).
All–Computational Uses Strategies:
• Also referred to as the ACU strategy.
• Definition:
ACU is a testing strategy derived from the
(ACU+P) strategy. But here, we do not include
a p-use for the variable if there are no c-uses
for the variable following each definition.
• It is therefore evident(obvious) that ACU is
weaker than (ACU+P).
Ordering the strategies:
All Paths
This shows the relative
strength of data flow & control
flow testing strategies.
All DU Paths
Test cases are based on the (ACU+P) & (APU+C) are in
Relative strength of parallel & hence
All Uses comparable
testing strategies.

All-C/Some-P All-P/Some-C

All-C Uses All Definitions All-P Uses

The strength of the testing


Branch
Branch & Statement are strategies reduces along the
control flow test strategies Direction of the arrow. For
Statement example, All-Uses is weaker
than All DU paths.
Done!!! Do feel free to get back
incase you have any questions 

Note: This did appear in earlier


papers. So please don’t skip!!

You might also like