Equivalence Partitioning
Equivalence Partitioning
There are different types of testing techniques and to identify which testing
technique to use and at which phase of software development life cycle we must
evaluate them thoroughly before categorizing them in any particular hierarchy.
Therefore, it is very crucial to have a detailed research of testing approach we want
to implement in our software product.
Software Testing can be broadly categorized in two basic approaches which are
functional testing and structural testing. In Functional Testing also known as Black
Box technique, the test cases are designed on the basis of specifications of the
software product only. It means the tester is not concerned with the internal
implementation of the software. On the other hand, Structural Testing also known
as White Box technique consider the internal structure of the software to design the
test cases. Both these methodologies are essential to software testing.
In this report, we have analyzed Equivalence Class Partitioning (ECP or EP) which
falls under the category of Black Box testing techniques.
Equivalence Class Partitioning
It is a type of Black Box testing technique in which the input domain of the program
is divided into different classes known as Equivalence classes. It is a better testing
technique than exhaustive testing which comprises of all combination inputs
possible in a system and is highly impractical. Here the challenge for the tester is to
design a minimal test suite that can reveal all the possible bugs and errors in the
software. There are broadly two approaches to find the equivalence classes of the
input domain. In one approach, we partition the input domain considering one
variable at an instance such that each input variable leads to a partition of the input
domain. This approach is called as Uni-dimensional Equivalence Class Partitioning.
Another approach is to consider the set product of different input variables and then
their association forms the input domain. This is known as Multi-dimensional
Equivalence Class Partitioning.
The main target of Equivalence Class Partitioning is to define a test suite that
unravels classes of errors and that helps in the reduction of total test classes to be
developed, thereby reducing both time and cost. Therefore, we can say that the
fundamental idea of Equivalence Class Partitioning is that it either works correctly
for all values in a class or it does not. The efficacy of test cases generated by this
method for any system is measured by the number of faults these tests are able to
expose to the total number of faults lyrking in that system.
Types of equivalence class testing:
Fig. 1. One variable is taken and that too only from valid equivalence classes.
In the figure given one variable is taken from each equivalence class. With respect
to the figure the square boxes represent the test cases and the test data are indicated
by each dot. Each class consists of one dot which means that there is one element
for each test case. Hence, the figure shows that we will have the same number of
weak normal equivalence class test cases as the classes in the partition.
➢ Strong normal equivalence class testing: Here it is assumed that errors result
in a combination of faults i.e. multiple fault assumption, where the variables are not
independent of each other. So, we test every combination of elements formed as a
result of the Cartesian product of the equivalence relation [7].
Fig.2. Test every combination of elements formed as a result of Cartesian product of the
equivalence relation
In the above figure, each test data is equally distributed among all the test cases.
With respect to the figure the square boxes represent the test cases and the test data
are indicated by each dot. Each class consists of one dot which means that there is
one element for each test case. These test cases work as same as truth tables in digital
logic’s making sure that we have got the similarities between these truth tables and
our pattern of test cases. The Cartesian product represents the ‘completeness’ in the
following ways:
1) Equivalence classes are covered.
2) We have possible combination of inputs at least one from each.
1. Firstly, determine the input domain of the program, after thoroughly analyzing the
requirements, which helps in identifying the input and output variables, their types,
and any constraints associated with their use.
2. Secondly, partition the input domain into various classes where the participants
of every class have some sort of relation with each other.
3. Thirdly, we expect that every test case from a class displays the same behavior.
Every class is thus, a separate equivalence class and we partition the set of values of
each variable into disjoint subsets which cover the entire domain, based on the
expected behavior.
In order to perform equivalence partitioning the tester should follow the guidelines
mentioned in Table II.
Range of values 1 2
Specific value 1 2
Element of a set 1 1
Boolean 1 1
So, the minimal test suite consists of 3 test cases representing each partition.
Test suite= {-4,6,15}
The same can be applied for date field in various combinations based on th e month
value.
3) Gender: char
The gender field has three possible inputs. Male (M), Female (F) or Other (O). Let
set G= {M, F, O} represents the valid class, then G’ represents the invalid
equivalence class.
void main ()
{
int month;
printf (“Enter month”);
scanf (“%d”, &month) if((month>=1) && (month< 12))
printf (“Valid month”);
elseprintf (“Invalid month”);
}
In the above case if we apply the equivalence partitioning test suite, we got the
following test status report.
Module under test: Month field of DOB
Test case Expected Result Actual Result Test result
-4 Invalid month Invalid month Successful
6 Valid month Valid month Successful
15 Invalid month Invalid month Successful
In the above table, random input values have been taken and output value is
compared with the expected result and actual result. If the expected result and the
actual result are same then the test result will be successful. If the expected result
and actual result are not same then the test result will be unsuccessful.
For example, let us take the first test case as the input number which is -4. When the
input is taken in the above code in place of month, it will not satisfy the if statement
and prints invalid month i.e.
The first condition if (month >= 1) which is false because -4 is not greater than 1.
The second condition if (month < 12) which is true because -4 is less than 12.
But if you observe the code an if statement has AND operator which means both the
conditions has to be true. In our test case where we have taken -4 as the input the
first condition is false and the pointer does not go to the second condition as the first
condition is false because it is AND operator.
Likewise, all the other test inputs have to be checked with both the conditions and
has to compare with the expected result and actual result. Thus, the above program
code works perfect for equivalence partitioning test suite. Now we analyze the same
program code
Results
In Equivalence class if there are ‘N’ partitions for the input set, then there will be
‘N’ test cases in the minimal test suite.
We analyzed our DOB module with the standard testing metrics.
1. Percentage of test cases passed - This value denotes the pass percentage of the
executed tests.
Test case pass % = (No. of test cases passed Total / No. of test cases) ×100
In ECP, Test case pass % = (3/3) × 100 = 100%
2. Minimal Test suite size - The number of test cases in a test suite. For our DOB
module, Minimal test suite size of ECP = 3
So, we can say that Equivalence class partitioning has lesser number of test cases
and thereby requires less testing time and effort to design the test cases.
REFERNCES
[1] S.U. Farooq, “Evaluating effectiveness of software testing techniques with emphasis
on enhancing software reliability” Ph.D. thesis.
[2] M.E. Khan, & F. Khan, “A Comparative Study of White Box, Black Box and Grey Box
Testing Techniques”. International Journal of Advanced Computer Sciences and
Applications, 3(6), pp. 12-1 ,2012.
[3] Ian Sommeriele, “Software Engineering”, Addison Wesley.
[4] Pressman, “Software Engineering –A Practitioner’s Approach”.
[5] P. Jalote - An integrated approach to software engineering. Springer, 1997.
[6] T. Murnane, K. Reed & R. Hall, “On the learnability of two representations of
equivalence partitioning and boundary value analysis.” In Proceedings of the 2007
Australian Software Engineering Conference (pp. 274-283). IEEE Computer Society-
April- 2007.
[7] G. Davies, “Equivalence Class Testing” Swansea University -2007
[8] T. Murnane, & K. Reed. “On the effectiveness of mutation analysis as a black box
testing technique.” In Software Engineering Conference, 2001. Proceedings. 2001
Australian (pp. 12-20). IEEE – 2001.
[9] B. B. Agarwal, S. P. Tayal & M. Gupta - Software Engineering and testing. Jones &
Bartlett Learning, 2010.
[10] Black-box testing. In Wikipedia, The Free Encyclopedia, from
https://en.wikipedia.org/wiki/Black-box_testing – October, 2019.
[11] D. Galin - Software quality assurance: from theory to implementation. Pearson
education, 2004.
[12] W. L. Huang & J. Peleska, “Equivalence Class Partitions for Exhaustive Model-Based
Testing” - 2012
[13] R. Mall, Fundamentals of software engineering. PHI Learning Pvt. Ltd – 2009