System Integration and
Architecture
1
Software Testing Techniques
Learning Objectives
At the end of the lesson, the learners are expected to:
• Differentiate Black Box from White Box Testing
• Give the importance of Black Box Testing
• Enumerate the techniques that can be used to implement Black
Box testing.
• Explain Equivalence Class Partitioning technique
• Implement Equivalence Class Partitioning techniques in testing
the functionality of a program.
• Explain Boundary value analysis.
• Implement Equivalence Class Partitioning techniques in testing
the functionality of a program.
2
Who Tests the Software?
developer independent tester
Understands the system Must learn about the system,
but, will test "gently" but, will attempt to break it
and, is driven by "delivery" and, is driven by quality
3
What is a “Good” Test?
a high probability of finding an error
not redundant.
neither too simple nor too complex
"Bugs lurk in corners
and congregate at
boundaries ..."
- Boris Beizer
OBJECTIVE: to uncover errors
CRITERIA: in a complete manner
CONSTRAINT: with a minimum of effort and time
4
Software Testing
White-Box Testing Black-Box Testing
requirements
output
... our goal is to ensure that all
statements and conditions have
been executed at least once ... input
events
5
Design of test cases
Number of test cases do not determine the
effectiveness
To detect error in following code
if(x>y) max = x; else max = x;
{(x=3, y=2); (x=2, y=3)} will suffice
{(x=3, y=2); (x=4, y=3); (x=5, y = 1)} will
falter
Each test case should detect different
errors
Black box testing
Equivalence class partitioning
Boundary value analysis
Comparison testing
Equivalence Class Partitioning
Input values to a program are partitioned
into equivalence classes.
Partitioning is done such that:
program behaves in similar ways to
every input value belonging to an
equivalence class.
Why define equivalence classes?
Test the code with just one representative
value from each equivalence class:
as good as testing using any other
values from the equivalence classes.
Equivalence Class Partitioning
How do you determine the equivalence
classes?
examine the input data.
few general guidelines for determining
the equivalence classes can be given
Equivalence Class Partitioning
If the input data to the program is specified
by a range of values:
e.g. numbers between 1 to 5000.
one valid and two invalid equivalence
classes are defined.
1 5000
Equivalence Class Partitioning
If input is an enumerated set of values:
e.g. {a,b,c}
one equivalence class for valid input
values
another equivalence class for invalid
input values should be defined.
Example
A program reads an input value in the
range of 1 and 5000:
computes the square root of the input
number
SQRT
Example
There are three equivalence classes:
the set of negative integers,
set of integers in the range of 1 and
5000,
integers larger than 5000.
1 5000
Example (cont.)
The test suite must include:
representatives from each of the three
equivalence classes:
a possible test suite can be:
{-5,500,6000}.
1 5000
Boundary Value Analysis
Some typical programming errors occur:
at boundaries of equivalence classes
might be purely due to psychological
factors.
Programmers often fail to see:
special processing required at the
boundaries of equivalence classes.
Boundary Value Analysis
Programmers may improperly use <
instead of <=
Boundary value analysis:
select test cases at the boundaries of
different equivalence classes.
Example
For a function that computes the square
root of an integer in the range of 1 and
5000:
test cases must include the values:
{0,1,5000,5001}.
1 5000