Thursday 9 May 2013

Software Testing by Equivalence Partitioning


Testing is a process which needs to be done effectively. Exhaustive testing is not possible due to limitation of sources. In past, it is observed that test cases lie in different classes. Equivalence classes are to form a partition of set, where partition refers to a collection of mutually disjoint subsets where the union is the entire set. This has two important implications for software testing: the fact that the entire set is represented provides a form of completeness and disjointedness ensures a form of non-redundancy. As the subsets are determined by a equivalence relation, the elements of one subset have something in common. So the idea is to identify test cases by using one element from each equivalence class. If the classes were chosen wisely, it greatly reduces the potential redundancy in test cases. For example for an equilateral triangle test case, if we chose (3, 3, 3) as test case, then we would not expect to learn much from (6, 6, 6) or (50, 50, 50). The key of equivalence class testing is the choice of the equivalence relation, which partition the classes. For the sake of drawings, a function F of two variables x1, x2 will be used [Jorgenson (2002)]. When F is implemented followings are the boundaries & intervals for the values of x1 and x2: -

a <= x1 <= d, with intervals (a,b), (b,c), (c,d)
e <= x2 <= g, with intervals (e,f), (f,g)

Invalid values for x1 and x2 are x1 < a, x1 > d and x2 < e, x2 > g.

For a more general example equivalence class partitions for a nextDate module, which return the very next date of the entered current date. Can be done as follows: -
It is a function of three variables and the boundaries are as follows: -
M1 = month (1 <= month <=12)
D1 = date (1 <= date <=31)
Y1 = year (1951 <= year <= 2051)

The invalid equivalence classes were: -
M2 = month < 1
M3 = month > 12
D2 = date < 1
D3 = date > 31
Y2 = year < 1951
Y3 = year > 2051

So the robust test cases with equivalence class test may be as follows:

Month                          Date                 Year                             Remarks
            5                                 15                    1962                            All valid inputs
-1                                15                    1962                            M2 class
15                                15                    1962                            M3 class
5                                  -1                     1962                            D2 class
5                                  45                    1962                            D3 class
5                                  15                    1900                            Y2 class
5                                  15                    2100                            Y3 class

No comments:

Post a Comment