White-Box Testing: Eshcar Hillel Michael Beder
White-Box Testing: Eshcar Hillel Michael Beder
Eshcar Hillel
Michael Beder
Tutorial Outline
G = (V, E) where
1, 2
- V is the set of basic blocks
- E is the set of control branches
F
end 3
Example:
Input: T
1. a = Read(b)
b=2
2. c=0 F
6 4
3. while (a > 1)
4. If (a^2 > c)
5. c=c+a Output:
a = 0, c = 2 T
6. a=a-2
5
A function f : D D
n n
represents the current values of the
variables as function of their initial values
Each variable X is represented by a projection function f X : D D
n
Function composition ( g f )(v ) g ( f X (v ),..., f X (v ))
1 n
– For example
f ( X , Y , Z ) ( X Y , X Y , XZ )
f X ( X ,Y , Z ) X Y fY ( X ,Y , Z ) X Y f Z ( X , Y , Z ) XZ
g ( X , Y , Z ) ( XY , X Z , Z )
( g f )( X , Y , Z ) g ( f X ( X , Y , Z ), fY ( X , Y , Z ), f Z ( X , Y , Z ))
g ( X Y , X Y , XZ ) (( X Y )( X Y ),( X Y ) XZ , XZ )
1. a = Read(b)
2. c=0
3. while (a > 1) 1, 2
4. if (a^2 > c)
5. c=c+a
6. a=a–2 F
end 3
Find test case for path:
p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end T
F
6 4
T
5
1. a = Read(b)
2. c=0
3. while (a > 1) 1, 2
4. if (a^2 > c)
5. c=c+a
6. a=a–2 F
end 3
1. a = Read(b)
2. c=0
3. while (a > 1)
1, 2
4. if (a^2 > c)
5. c=c+a
6. a=a–2 F
end 3
p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end
vertex path function path condition T
6 (B, B, B) B>1
3 (B-2, B, B) B>1
F
4 (B-2, B, B) (B>1 Λ B-2>1) ↔ B>3 6 4
5 (B-2, B, B) (B>3 Λ (B-2)^2>B) ↔ B>4
6 (B-2, B, 2B-2) B>4
3 (B-4, B, 2B-2) B>4
T
end (B-4, B, 2B-2) (B>4 Λ B-4<=1) ↔ B=5
5
1. a = Read(b)
2. c=0
1, 2
3. while (a > 1)
4. if (a^2 > c)
5. c=c+a F
end 3
6. a=a–2
T
p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end
F
end (B-4, B, 2B-2) B=5 6 4