0% found this document useful (0 votes)
43 views14 pages

White-Box Testing: Eshcar Hillel Michael Beder

White-box testing is a software testing method that tests internal program structure and logic flow. It uses test cases designed based on the internal details of the system such as code structure, code coverage, internal variables and algorithms. The document discusses flow graphs and different types of white-box testing techniques such as statement coverage, branch coverage and path coverage. It also explains symbolic execution which is used to derive test cases that satisfy a given path condition in the program.

Uploaded by

psaiswarya22
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views14 pages

White-Box Testing: Eshcar Hillel Michael Beder

White-box testing is a software testing method that tests internal program structure and logic flow. It uses test cases designed based on the internal details of the system such as code structure, code coverage, internal variables and algorithms. The document discusses flow graphs and different types of white-box testing techniques such as statement coverage, branch coverage and path coverage. It also explains symbolic execution which is used to derive test cases that satisfy a given path condition in the program.

Uploaded by

psaiswarya22
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

White-Box Testing

Eshcar Hillel
Michael Beder
Tutorial Outline

 What is White Box Testing?


 Flow Graph and Coverage Types
 Symbolic Execution:
– Formal Definition
– Examples

2 White Box Testing


White-Box means
Testing by Implementation

 Execution-based testing that uses the program’s


inner structure and logical properties
– A.K.A Clear Box, Glass Box and Structural Testing
 There are different types of white-box testing
– For example statement coverage where each statement is
executed at least once
 Flow Graph helps us model an analyze different
types of coverage

3 White Box Testing


Flow Graph start

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

4 White Box Testing


White Box Coverage Types

 Statement Coverage: Every statement is executed


 Branch Coverage: Every branch option is chosen
 Path Coverage: Every path is executed
 Basic Path Coverage: Loops?
– We need to define basic path set first

5 White Box Testing


Basic Path Set

 An execution path is a set of nodes and directed


edges in a flow graph that connects (in a directed
fashion) the start node to a terminal node.
 Two execution paths are said to be independent if
they do not include the same set of nodes and
edges.
 A basic set of execution paths for a flow graph is an
independent maximum set of paths in which all
nodes and edges of the graph are included at least
once.

6 White Box Testing


Basic Path Coverage start

 The number of Basic paths is 1, 2


E – N + 2 (Linear Complexity)
F
end 3
 Example
T
p1 = start – 1,2 – 3 – end
F
p2 = start – 1,2 – 3 – 4 – 6 – 3 – end 6 4

p3 = start – 1,2 – 3 – 4 – 5 – 6 – 3 – end


T
5
E–N+2=8–7+2=3

7 White Box Testing


Path Function

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 )

8 White Box Testing


Path Condition
start

 A condition that ensures the execution of a path


 A constraint on the initial values of the variables
1, 2

For Example: p = start – 1,2 – 3 – end.


1. a = Read(b) F
2. c=0 end 3
3. while (a > 1) T
4. if (a^2 > c)
5. c=c+a F
6 4
6. a=a–2

The path condition is B <= 1, where B is the initial value of b


T
5

9 White Box Testing


Symbolic Execution
 A method for deriving test cases which satisfy a given path
– Outputs path condition (input) and path function (expected result)
 Initially
– Path function is the Identity function
– Path condition is true
 Each step in the path induce a symbolic composition on the
path function or a logical constraint on the path condition
– Simple block g(x): f  g  f
– Control branch: C  C  branch condition

10 White Box Testing


Example: Symbolic Execution
start

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

11 White Box Testing


Example: Symbolic Execution
start

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 T


vertex path function path condition
start: (A, B, C) true F
6 4
1,2 (A, B, C) true
3 (B, B, 0) true
4 (B, B, 0) (true Λ B>1) ↔ B>1
5 (B, B, 0) (B>1 Λ B^2>0) ↔ B>1 T
5

12 White Box Testing


Example: Symbolic Execution
start

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

13 White Box Testing


Example: Symbolic Execution
start

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

Hence the test case is B = 5


T
and the expected result is 2B-2 = 8
5
Is there a test case for
p = start – 1,2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end ?
14 White Box Testing

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy