This action might not be possible to undo. Are you sure you want to continue?

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. Glass Box and Structural Testing For example statement coverage where each statement is executed at least once There are different types of white-box testing – Flow Graph helps us model an analyze different types of coverage 3 White Box Testing .A Clear Box.

c = 2 5 T 4 White Box Testing . while (a > 1) 4. c=0 3. a = Read(b) 2.Flow Graph G = (V.V is the set of basic blocks . c=c+a 6. E) where . 2 F 3 Example: 1. a=a-2 Input: b=2 6 T F 4 Output: a = 0.E is the set of control branches end start 1. If (a^2 > c) 5.

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 .

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. Two execution paths are said to be independent if they do not include the same set of nodes and edges. 6 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.

2 – 3 – 4 – 6 – 3 – end p3 = start – 1.2 – 3 – end 6 p2 = start – 1. 2 Example p1 = start – 1.2 – 3 – 4 – 5 – 6 – 3 – end E–N+2=8–7+2=3 end 3 T F 4 T 5 7 White Box Testing .Basic Path Coverage The number of Basic paths is E – N + 2 (Linear Complexity) F start 1.

Z ) ( g o f )( X . Y . Z ) = ( XY . Z ) = XZ g ( X . XZ ) = (( X + Y )( X − Y ). Y . f X (v )) – For example 1 n f ( X . Z ) = ( X + Y . Y .( X + Y ) + XZ . Z )) = = g ( X + Y . Z ).. X − Y . XZ ) f X ( X .Y .. X + Z . Z ). f Z ( X . fY ( X .Path Function A function f : D n → D 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 n → D Function composition ( g o f )(v ) = g ( f X (v ). Y . Z ) = X − Y f Z ( X . Y . XZ ) 8 White Box Testing . Y . Y .. Z ) = X + Y fY ( X . X − Y . Y .. Z ) = g ( f X ( X .

4. p = start – 1. 3. 5. a = Read(b) c=0 while (a > 1) if (a^2 > c) c=c+a a=a–2 F end 3 T 6 F 4 The path condition is B <= 1.2 – 3 – end. where B is the initial value of b 5 T 9 White Box Testing . 2. 6. 2 For Example: 1.Path Condition start A condition that ensures the execution of a path A constraint on the initial values of the variables 1.

Symbolic Execution A method for deriving test cases which satisfy a given path – Outputs path condition (input) and path function (expected result) Path function is the Identity function Path condition is true Initially – – 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 o f Control branch: C ← C ∧ branch condition 10 White Box Testing .

c=c+a 6. 2 F end 3 T 6 F 4 T 5 11 White Box Testing . if (a^2 > c) 5. c = 0 3. while (a > 1) 4.2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end 1.Example: Symbolic Execution start a = Read(b) 2. 1. a=a–2 Find test case for path: p = start – 1.

0) true 4 (B. 0) (true Λ B>1) ↔ B>1 5 (B. 2 F end 3 p = start – 1. 4. B. C) true 3 (B. 5.2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end vertex path function path condition start: (A. B. B. B. 2. 0) (B>1 Λ B^2>0) ↔ B>1 T 6 F 4 T 5 12 White Box Testing . 6. B. C) true 1.Example: Symbolic Execution start 1. 3.2 (A. a = Read(b) c=0 while (a > 1) if (a^2 > c) c=c+a a=a–2 1.

B) B>1 4 (B-2. B. 4. 2 F 3 p = start – 1. 3. B) B>1 3 (B-2. 2B-2) B>4 3 (B-4. B. 2B-2) (B>4 Λ B-4<=1) ↔ B=5 T 6 F 4 T 5 13 White Box Testing . B) (B>3 Λ (B-2)^2>B) ↔ B>4 6 (B-2. 6. B) (B>1 Λ B-2>1) ↔ B>3 5 (B-2. 2B-2) B>4 end (B-4. a = Read(b) c=0 while (a > 1) if (a^2 > c) c=c+a a=a–2 end 1. B. B. B.2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end vertex path function path condition 6 (B. B. 2. B. 5.Example: Symbolic Execution start 1.

5. 2 F end 3 T p = start – 1. 2B-2) B=5 Hence the test case is B = 5 and the expected result is 2B-2 = 8 5 6 F 4 T 14 Is there a test case for p = start – 1.2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end ? White Box Testing . B. a = Read(b) c=0 while (a > 1) if (a^2 > c) c=c+a a=a–2 1. 6.Example: Symbolic Execution start 1. 2.2 – 3 – 4 – 5 – 6 – 3 – 4 – 5 – 6 – 3 – end end (B-4. 3. 4.

this is an article on white box testing

this is an article on white box testing

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd