Created By
Ronak Ahir (ME-CSE) Enrolment No : 140870702501
Ankit Mulani (ME-CSE) Enrolment No : 140870702504
 White Box Testing
 Control Flow & Control Flow Graph
 Loop Testing
Designing white-box test cases:
Requires knowledge about the
internal structure of software.
White-box testing is also called
structural testing.
 Statement coverage
 Branch coverage
 Path coverage
 Condition coverage
There Exist Several Popular White-
box Testing Methodologies
 Design test cases so that every
statement in a program is
executed at least once.
 The Principal Idea
 Unless a statement is executed,
 We have no way of knowing if an error exists in
that statement
 Based on the observation
 An error in a program can not be Discovered
 Unless the part of the program containing the
error is executed
 Test cases are designed such that
 different branch conditions
 given true and false values in turn
 Branch Testing guarantees statement coverage
 A stronger testing compared to the statement
coverage-based testing
 Why “…and that every program entry point will
have been taken, at least once”?
 Design test cases such that
 All linearly independent paths
in the program are executed at
least once.
 It is straight forward
 To identify linearly independent
paths of simple programs
 For complicated programs
 It is not so easy to determine the
number of independent paths
The Tester Proposes
An Initial set of test data using
his experience and Judgment
 Test cases are designed such that
 each component of a composite conditional
expression given both true and false values
 If We Consider a Boolean expression having n
components
 Then For condition coverage we require 2n
test
cases
if A or B then
s1
else
s2
end_if_then_else
if A or B then
s1
else
s2
end_if_then_else
 To Understand the Path Coverage-Based
Testing We Need to Learn How to Draw
Control Flow Graph of a Program
 A Control Flow Graph (CFG) Describes
 The Sequence in which Different Instructions
of a Program get Executed
 The Way Control Flows Through the Program
 Number all the Statements of a Program
 Numbered Statements Represent nodes of the
Control Flow Graph.
 An Edge from one node to another node exists
 If execution of the statement representing the
first node can result in transfer of control to
the other node.
Flow Graph Example
1
2
0
3
4
5
6
7 8
9
1011
1
2
3
46
7 8 5
9
1011
R1
R2
R3
R4
FLOW CHART FLOW GRAPH
0
Example of Control Flow
Graph
1
2
3 4
5
6
 A white-box testing technique that focuses
exclusively on the validity of loop constructs
 Four different classes of loops exist
 Simple loops
 Nested loops
 Concatenated loops
 Unstructured loops
 Testing occurs by varying the loop boundary
values
 Skip the loop entirely
 Only one pass through the loop
 Two passes through the loop
 m passes through the loop, where m < n
 n –1, n, n + 1 passes through the loop
Note : ‘n’ is the maximum number of allowable passes through the loop
 Start at the innermost loop ; set all other loops to
minimum values
 Conduct simple loop tests for the innermost loop
while holding the outer loops at their minimum
iteration parameter values; add other tests for out-
of-range or excluded values
 Work outward, conducting tests for the next loop,
but keeping all other outer loops at minimum
values and other nested loops to “typical” values
 Continue until all loops have been tested
 For independent loops, use the same approach as
for simple loops
 Otherwise, use the approach applied for nested
loops
 Redesign the code to reflect the use of structured
programming practices
 Depending on the resultant design, apply testing
for simple loops, nested loops, or concatenated
loops
White Box Testing And Control Flow & Loop Testing
White Box Testing And Control Flow & Loop Testing

White Box Testing And Control Flow & Loop Testing

  • 2.
    Created By Ronak Ahir(ME-CSE) Enrolment No : 140870702501 Ankit Mulani (ME-CSE) Enrolment No : 140870702504
  • 3.
     White BoxTesting  Control Flow & Control Flow Graph  Loop Testing
  • 4.
    Designing white-box testcases: Requires knowledge about the internal structure of software. White-box testing is also called structural testing.
  • 5.
     Statement coverage Branch coverage  Path coverage  Condition coverage There Exist Several Popular White- box Testing Methodologies
  • 6.
     Design testcases so that every statement in a program is executed at least once.
  • 7.
     The PrincipalIdea  Unless a statement is executed,  We have no way of knowing if an error exists in that statement  Based on the observation  An error in a program can not be Discovered  Unless the part of the program containing the error is executed
  • 8.
     Test casesare designed such that  different branch conditions  given true and false values in turn  Branch Testing guarantees statement coverage  A stronger testing compared to the statement coverage-based testing
  • 9.
     Why “…andthat every program entry point will have been taken, at least once”?
  • 10.
     Design testcases such that  All linearly independent paths in the program are executed at least once.
  • 11.
     It isstraight forward  To identify linearly independent paths of simple programs  For complicated programs  It is not so easy to determine the number of independent paths
  • 12.
    The Tester Proposes AnInitial set of test data using his experience and Judgment
  • 13.
     Test casesare designed such that  each component of a composite conditional expression given both true and false values  If We Consider a Boolean expression having n components  Then For condition coverage we require 2n test cases
  • 14.
    if A orB then s1 else s2 end_if_then_else if A or B then s1 else s2 end_if_then_else
  • 15.
     To Understandthe Path Coverage-Based Testing We Need to Learn How to Draw Control Flow Graph of a Program  A Control Flow Graph (CFG) Describes  The Sequence in which Different Instructions of a Program get Executed  The Way Control Flows Through the Program
  • 16.
     Number allthe Statements of a Program  Numbered Statements Represent nodes of the Control Flow Graph.  An Edge from one node to another node exists  If execution of the statement representing the first node can result in transfer of control to the other node.
  • 17.
    Flow Graph Example 1 2 0 3 4 5 6 78 9 1011 1 2 3 46 7 8 5 9 1011 R1 R2 R3 R4 FLOW CHART FLOW GRAPH 0
  • 18.
    Example of ControlFlow Graph 1 2 3 4 5 6
  • 19.
     A white-boxtesting technique that focuses exclusively on the validity of loop constructs  Four different classes of loops exist  Simple loops  Nested loops  Concatenated loops  Unstructured loops  Testing occurs by varying the loop boundary values
  • 20.
     Skip theloop entirely  Only one pass through the loop  Two passes through the loop  m passes through the loop, where m < n  n –1, n, n + 1 passes through the loop Note : ‘n’ is the maximum number of allowable passes through the loop
  • 21.
     Start atthe innermost loop ; set all other loops to minimum values  Conduct simple loop tests for the innermost loop while holding the outer loops at their minimum iteration parameter values; add other tests for out- of-range or excluded values  Work outward, conducting tests for the next loop, but keeping all other outer loops at minimum values and other nested loops to “typical” values  Continue until all loops have been tested
  • 22.
     For independentloops, use the same approach as for simple loops  Otherwise, use the approach applied for nested loops
  • 23.
     Redesign thecode to reflect the use of structured programming practices  Depending on the resultant design, apply testing for simple loops, nested loops, or concatenated loops