0% found this document useful (0 votes)
4 views15 pages

White Box Testing

White box testing is a code-based testing strategy that focuses on the internal structure and implementation of software, requiring strong programming skills. Control flow testing is a key technique within white box testing that identifies execution paths in code and creates test cases to ensure all statements and conditions are executed. While effective for unit testing, it can be time-consuming and requires the tester to have a good understanding of the code's control flow.

Uploaded by

pivoke4989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views15 pages

White Box Testing

White box testing is a code-based testing strategy that focuses on the internal structure and implementation of software, requiring strong programming skills. Control flow testing is a key technique within white box testing that identifies execution paths in code and creates test cases to ensure all statements and conditions are executed. While effective for unit testing, it can be time-consuming and requires the tester to have a good understanding of the code's control flow.

Uploaded by

pivoke4989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

White Box Testing Techniques

White-Box Testing

... our goal is to ensure that all


statements and conditions have
been executed at least once ...
White Box Testing or Code Based Techniques

•Control Flow
Testing
•Data Flow Testing
White Box Testing
White box testing is a strategy in which testing is based
on the internal paths, structure, and implementation of
the software under test. Unlike black box testing, white
box testing generally requires good programming skills.
Control Flow Testing
Control Flow Testing
• This testing approach identifies the execution paths through a module
of program code and then creates and executes test cases to cover
those paths
• A Path is a sequence of statement execution that begins at an entry
and ends at an exit.
How it Works?
• Control Flow Graphs Document the Control Structure of the Code
Modules
• Modules of the Code are Converted to Control Flow Graphs
• Paths through the Graphs are Analyzed
• Test Cases are Created against Paths
Control Flow Graphs
• A process block is a sequence of program
statements that execute sequentially from
beginning to end.
• A decision point is a point in the module at
which the control flow can change.
• A junction point is a point at which control
flows join together.
Control Flow Graphs
Levels of Coverage: Level—1
100% Statement Coverage
• Every Statement within the Module is Executed at Least Once During Testing.
• Execution of All Statements Does Not Necessarily Mean Execution of All Paths
• For Example: Use a = 6, b = 3

if (a>0) {x=x+1;} Control Flow Paths 1, 2 Control Flow Paths 3, 4


if (b==3) {y=0;}
Levels of Coverage: Level—2
100% Decision/Branch Coverage
• Test cases are written so that each decision that has a TRUE and
FALSE outcome is evaluated at least once

• Decision coverage does not necessarily guarantee path coverage


but it does guarantee statement coverage
if (a>0) {x=x+1;} Test Case1: a=-2, b=2 Test Case 2: a=4, b=3
if (b==3) {y=0;}
Levels of Coverage: Level—3
100% Condition Coverage
• Test cases are written so that each condition that has a TRUE and FALSE outcome
that makes up a decision is evaluated at least once.
• Condition Coverage does not necessarily means Decision Coverage

if (a>0 && c==1) Test Case 1 Input: a=3, c=1, b=3, d=-2
{x=x+1;} and
if (b==3 || d<0) Test Case 2 Input: a=0, c=2, b=1, d=4
{y=0;}
Levels of Coverage: Level—4
100% Decision & Condition Coverage
• At this Level, Test cases are created for every condition and every
decision

if(x&&y) Test Case Input 1: x=TRUE, y=FALSE


{ z = z + 1;} and
Test Case Input 2: x=FALSE, y=TRUE
//x and y are boolean
//&& is logical AND /*the statement z=z+1 will never get
executed. More test cases needs to be
written */
Test Case Input 3: x=TRUE, y=TRUE
Levels of Coverage: Level—5
Consider How Compiler Evaluates Multiple Conditions to Achieve 100%
Multiple Condition Coverage
• Achieving 100% multiple condition coverage also achieves decision coverage,
condition coverage, and decision/condition coverage but does not guarantee
path coverage.

Test Cases Inputs

if (a>0 && c==1) 1. a>0, c=1, b=3, d<0


{x=x+1;}
if (b==3 || d<0) 2. a≤0, c=1, b=3, d≥0
{y=0;}
3. a>0, c≠1, b≠3, d<0

4. a≤0, c≠1, b≠3, d≥0


Application and Limitations
• Control flow testing is the cornerstone of unit testing.
• It should be used for all modules of code that cannot be tested
sufficiently through reviews and inspections.
• A limitations is that the tester must have sufficient programming skill
to understand the code and its control flow.
• Control flow testing can be very time consuming if there are large
number of modules and a large number of basis paths.

You might also like