White Box Testing
White Box Testing
TESTING
Designed By:
White box testing strategy deals with the internal logic and structure of
the code. White box testing is also called as glass, structural, open box or
clear box testing. The tests written based on the white box testing
strategy incorporate coverage of the code written, branches, paths,
statements and internal logic of the code etc.
In order to implement white box testing, the tester has to deal with the
code and hence is needed to possess knowledge of coding and logic i.e.
internal working of the code. White box test also needs the tester to look
into the code and find out which unit/statement/chunk of the code is
malfunctioning.
Advantages of White box testing are:
ii) And it is nearly impossible to look into every bit of code to find out
hidden errors, which may create problems, resulting in failure of the
application.
White box testing generates the test cases that:
•Guarantees that all the independent paths with in a
module have been exercised at least once
•Exercise all logic decisions on their true and false
sides
•Execute all loops at their boundaries and with in
their operational bounds
•Exercise internal data structures to ensure their
validity
White box testing techniques:
•Statement Coverage
•Decision coverage
•Condition coverage
•Basis path testing
•Loop testing
•Data flow testing
Statement coverage:
This technique attempts to write enough
test cases to execute every statement at least
once
Decision coverage :
This technique is used to write test
cases to exercise the true and false
outcomes of every decision
Condition coverage:
This technique is used to write test
cases such that each condition in a
decision takes on all possible outcomes
at least once. It may not always satisfy
decision coverage.
Basis path testing:
It is a white box testing technique first
proposed by Tom McCabe which is based on
the fact that every statement in the program
must be executed at least once during testing
It uses certain notations and concepts for
representing the control flow which are:
•Flow graph notation
•Cyclomatic complexity
•Graph Matrices
1 Nodes
22
Edges
3 4
Region
5 6
Cyclomatic Complexity:
This is a quantitative measure of the
logical complexity of a program.the
calculated value of cyclomatic
complexity defines the number of
independent paths.
The cyclomatic complexity V(G) of
the flow graph can be computed
using any of the formulas:
V(G) = Edges – Nodes + 2
Or V(G) = Regions in flow graph
Or V(G) = Predicate Nodes +1
Graph Matrices
A Graph Matrix is a square matrix that assists in
basis path testing whose size is equal to the
number of nodes in the flow graph
Example
Int compute_gcd (intx,inty){
1. While (x! =y){
2. If (x>y) then
3. X=x-y;
4. Else y=y-x;
5. }
6. Return x;
}
Loop testing:
It is a white box testing technique that checks
the validity of the loop constructs.
Loop can be classified into four types:
•Simple loops
•Nested loops
•Concatenated loops
•Unstructured loops
Data Flow Testing;
This is the type of control structure
testing that selects the test plans of a
program according to the variable
definition and its use in the program
Different Types of Testing
Automated v/s manual