2 - Equivalent Partition Testing
2 - Equivalent Partition Testing
1
Black-box Testing
Testcases are designed using only
functional specification of the software:
◦ without any knowledge of the internal
structure of the software.
Forthis reason, black-box testing is
also known as functional testing.
2
Errors detected by black box
testing
Black-box testing attempts to find errors
in the following categories:
1. To test the modules independently .
2. To test the functional validity of the
software so that incorrect or missing
functions can be recognized.
3. To look for interface errors. „
3
Errors detected by black box
testing
4. To test the system behavior and check
its performance „.
5. To test the maximum load or stress on
the system.
6. To test the software such that the
user/customer accepts the system
within defined acceptable limits.
4
Black-box Testing Techniques
There are many approaches to design
black box test cases:
◦ Equivalence class partitioning
◦ Boundary value analysis
◦ State table based testing
◦ Decision table based testing
◦ Cause-effect graph based testing
◦ Orthogonal array testing
◦ Positive-negative testing
5
Black-box Testing
6
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.
7
Why define equivalence classes?
Testthe code with just one
representative value from each
equivalence class:
◦ as good as testing using any other
values from the equivalence classes.
8
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
9
Equivalence Class Partitioning
Ifthe 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
10
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.
11
Example - 1
Aprogram reads an input value in
the range of 1 and 5000:
◦ computes the square root of the
input number
SQR
T
12
Example - 1 (cont.)
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
13
Example - 1(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
14
Example - 2
A program reads three numbers, A, B, and
C, with a range [1, 50] and prints the
largest number. Design test cases for this
program using equivalence class testing
technique.
15
Solution
1. First we partition the domain of input as
valid input values and invalid values,
getting the following classes:
I1 = {<A, B, C> : 1 ≤ A ≤ 50}
I2 = {<A, B, C> : 1 ≤ B ≤ 50}
I3 = {<A, B, C> : 1 ≤ C ≤ 50}
I4 = {<A, B, C> : A < 1}
16
Solution
I5 = {<A, B, C> : A > 50}
I6 = {<A, B, C> : B < 1}
I7 = {<A, B, C> : B > 50}
I8 = {<A, B, C> : C < 1}
I9 = {<A, B, C> : C > 50}
17
Solution
Now the test cases can be designed from
the above derived classes, taking
◦ one test case from each class such that the test
case covers maximum valid input classes, and
◦ separate test cases for each invalid class.
18
Solution
The test cases are shown below:
19
Solution
2. We can derive another set of equivalence
classes based on some possibilities for
three integers, A, B, and C. These are given
below:
I1 = {<A, B, C> : A > B, A > C}
I2 = {<A, B, C> : B > A, B > C}
I3 = {<A, B, C> : C > A, C > B}
20
Solution
I4 = {<A, B, C> : A = B, A ≠ C}
I5 = {<A, B, C> : B = C, A ≠ B}
I6 = {<A, B, C> : A = C, C ≠ B}
I7 = {<A, B, C> : A = B = C}
21
Solution
22
Example - 3
A program determines the next date in
the calendar. Its input is entered in the
form of with the following range:
1 ≤ mm ≤ 12
1 ≤ dd ≤ 31
1900 ≤ yyyy ≤ 2025
23
Example
Its output would be the next date or an
error message ‘invalid date.’ Design test
cases using equivalence class partitioning
method.
24
Solution
First, we partition the domain of input in
terms of valid input values and invalid
values, getting the following classes:
I1 = { <m, d, y> : 1 ≤ m ≤ 12}
I2 = {<m, d, y> : 1 ≤ d ≤ 31}
I3 = {<m, d, y> : 1900 ≤ y ≤ 2025}
I4 = {<m, d, y> : m < 1}
25
Solution
26
Solution
The test cases can be designed from the
above derived classes,
◦ taking one test case from each class such that
the test case covers maximum valid input
classes, and
◦ separate test cases for each invalid class.
The test cases are shown in next slide.
27
Solution
28
Example - 4
A program takes an angle as input within
the range [0, 360] and determines in
which quadrant the angle lies. Design test
cases using equivalence class partitioning
method.
29
Solution
1. First, we partition the domain of input as
valid and invalid classes as follows:
I1 = {<Angle> : 0 ≤ Angle ≤ 360}
I2 = {<Angle> : Angle < 0}
I3 = {<Angle> : Angle > 360}
30
Solution
The test cases designed from these
classes are shown below:
31
Solution
2. The classes can also be prepared based
on the output criteria as shown below:
O1 = {<Angle>: First Quadrant, if 0 ≤
Angle ≤ 90}
O2 = {<Angle>: Second Quadrant, if 91 ≤
Angle ≤ 180}
O3 = {<Angle>: Third Quadrant, if 181 ≤
Angle ≤ 270}
32
Solution
O4 = {<Angle>: Fourth Quadrant, if 271
≤ Angle ≤ 360}
O5 = {<Angle>: Invalid Angle};
However, O5 is not sufficient to cover all
invalid conditions this way. Therefore, it
must be further divided into equivalence
classes as shown in next slide:
33
Solution
O51={<Angle>: Invalid Angle, if Angle > 360}
O52={<Angle>: Invalid Angle, if Angle < 0}
34
Solution
Now, the test cases can be designed from
the above derived classes as shown
below:
35
Summary
Discussed the errors detected by
black-box test testing techniques.
Explained equivalence partitioning
technique with some examples.
36
References
1. Rajib Mall, Fundamentals of Software Engineering,
(Chapter – 10), Fifth Edition, PHI Learning Pvt.
Ltd., 2018.
2. Naresh Chauhan, Software Testing: Principles and
Practices, (Chapter – 4), Second Edition, Oxford
University Press, 2016.
Thank You
38