We will learn
Data flow coverage criteria
Comparison of criteria
Excercise
Last time
Control Flow criteria
Black box
Equivalence partitions Boundary values Statement coverage Branch coverage Path coverage Condition, multiple condition coverage
White box
Graph ~ FSM (Finite State Machine) ~ EFSM (Extended FSM) ~ State machine diagram, activity diagram ~ ...
= Assignment (x = a + b)
== Equal (a == b) != Not Equal (a != b) >, <, >=, <=
Comparison
For computation a=x+2 (c-use, computation use) In the predicate x==0 (p-use, predicate use)
x=1 x=2 X!=1 x==1
Definitions
x is defined on the edge ed, used on the edge
eu On the path ed, e1, ... , en, eu x is not redefined on sub-path e1, ..., en. If the previous holds, then the sub-path e1, ..., en is definition-clear path for x In other words, x is not redefined on this subpath, x holds the same value
coverage is reached, when tests execute at least one path from i to some use of x In other words: all-defs criterion requires, that every definition of x has at least one use (predicate or computational)
x=1 k=x+2 x<3 k=k+2
x=2
k=x+1
y=0
y=y+1
uses criterion requires a test set, where tests excecute at least one path from every i to every edge, where the assigned value of x is used In other words: at least one path from each definition of x to every use of this definition
4}, {1, 2, 3, 4, 5}
x=1
1 3
k=x+2
4
x<3 k=k+2
5
x=2
k=x+1
y=0
y=y+1
to every use of this definition in a predicate All-c-uses at least one path from defining x to every use of this definition in computation
x=2
k=x+1
y=0
y=y+1
criterion requires tests to excecute all paths from every definition of x to every use of each definition In other words: all possible paths form defininig x to its use
x=1 1 3 k=x+2 4 x<3 k=k+2 5
x=2
k=x+1
y=0
y=y+1
All-du-paths: {1, 3, 4}, {1,3,4,5}, {1,3,6,4,5}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 6, 4, 5}
Strength of criteria
All-paths Stronger All-du-pairs All-uses All-c-uses All-defs All-p-uses
Weaker
Related issues
Which tests (paths) should be excecuted to
achieve certain coverage? (test sequence generation problem) Which paths (program statements) can not be excecuted? (problem of finding infeasible paths dead code) How to find data, that allows to excecute tests for certain coverage? (test data generation problem)
Exercise
Find paths for x that
x=read(x) y=read(y)
max=x
3
x>y
x<y
4
max = y
Exercise
Find paths for x that
x=read(x) y=read(y)
max=x
3
x>y
x<y
4
max = y
All-defs: {1,2,3} All-uses:{1,2,3}, {1,2,3,4}, {1,2,3,5}, All-p-uses: {1,2,3,4}, {1,2,3,5} All-c-uses: {1,2,3} All-du-paths = all-uses + {1,2,3,4,5}