Class 19
Class 19
1
White-Box Testing
● There exist several popular white-box
testing methodologies:
● Statement coverage
● Branch coverage
● Condition coverage
● Path coverage
● Data flow-based testing
● Mutation testing
2
Data Flow-Based Testing
3
Data Flow-Based Testing
4
DU Example
1 X(a){
2 a=5; /* Defines variable a */
3 while(C1) {
4 if (C2)
5 b=a*a; /*Uses variable a */
6 a=a-1; /* Defines & uses variable a */
7 }
8 print(a); } /*Uses variable a */
5
6
Data Flow-Based Testing
● A variable X is said to be
live at statement S1, if
–X is defined at a statement S,
and
– There exists a path from S to
S1 not containing any
definition of X.
7
Definition-use chain (DU
chain)
● [X,S,S1],
– S and S1 are statement numbers,
– X in DEF(S)
– X in USES(S1), and
– the definition of X in the statement S
is live at statement S1.
8
Data Flow-Based Testing
● One simple data flow testing
strategy:
– Every DU chain in a program be
covered at least once.
● Data flow testing strategies:
– Useful for selecting test paths of
a program containing nested if and
loop statements.
9
Data Flow-Based Testing
● 1 X(){
● 2 B1; /* Defines variable a */
● 3 While(C1) {
● 4 if (C2)
● 5 if(C4) B4; /*Uses & defines variable a */
● 6 else B5;
● 7 else if (C3) B2;
● 8 else B3; }
● 9 B6 }
10
Data Flow-Based Testing
● [a,1,5]: a DU chain.
● Assume:
– DEF(X) = {B1, B2, B3, B4, B5}
– USED(X) = {B2, B3, B4, B5, B6}
– There are 25 DU chains.
11
Mutation Testing
● The software is first tested:
– using an initial testing method based on
white-box strategies we already discussed.
12
Mutation Testing
13
Mutation Testing
● A mutated program:
– tested against the full test suite of the
program.
14
Mutation Testing
● If a mutant remains alive:
– even after all test cases have been
exhausted,
– the test suite is enhanced to kill the mutant.
15
Mutation Testing
● The primitive changes can be:
– altering an arithmetic operator,
– changing the value of a constant,
– changing a data type, etc.
16
Mutation Testing
● A major disadvantage of
mutation testing:
– computationally very expensive,
– a large number of possible
mutants can be generated.
17
Cause and Effect Graphs
● Testing would be a lot easier:
– if we could automatically generate
test cases from requirements.
● Work done at IBM:
– Can requirements specifications be
systematically used to design
functional test cases?
18
Cause and Effect Graphs
● Examine the requirements:
– restate
them as logical relation
between inputs and outputs.
– Theresult is a Boolean graph
representing the relationships
● called a cause-effect graph.
19