1. Definition
Equivalence Partitioning technique is a method of dividing the input conditions into equal areas. All values in an equivalent region will give the same output. Therefore, we can test a representative value in the equivalent region.
2. Classification of equivalence testing
Equivalence class testing is divided into several categories. Consider a general problem for a function of three variables a, b, c and the input space is three sets A, B, C. Assume that we have defined equivalent domains for each input space:
A = A1 ∪A2 ∪A3
B = B1 ∪B2 ∪B3 ∪B4
C = B1 ∪C2
We denote the elements of the above equivalent domain in lowercase with the same index in the following sections. For example a1 ∈ A1, b3 ∈ B3 and c2 ∈ C2.
2.1. Weak equivalence test
Weak equivalence test only requires each equivalent space with at least one element to appear in a test case. Suppose the program has input space of three variables A, B, C, and the equivalent domains for each input space are:
A = A_1∪ A_2∪ A_3
B = B_1∪ B_2∪ B_3∪ B_4
C = C_1∪ C_2
Then we need to have a value of A_1 in a test case (eg a_1∈A_1). And the same with other subsets. The minimum number of test cases is the largest number of equivalence classes of the input domain.
No. | a | b | c |
---|---|---|---|
first | a_1 | b_1 | c_1 |
2 | a_2 | b_2 | c_2 |
3 | a_3 | b_3 | c_1 |
4 | a_1 | b_4 | c_2 |
For example, on equivalence testing for selecting the start and end time of a meeting (Time is selected from the calender box). It is not allowed to create meeting schedule with the same time. We have the equivalent areas are:
Location = {A, B}
Start date = {Valid Nbd, Nbđ <X, Nbđ = Duplicate}
End date = {Nkt = valid | Nkt ≤Nbd | Nkt = Duplicate}
Where: X is the current day. Suppose X = 9/8
A is the venue for the meeting scheduled from August 15 to August 16
B is a place where no meetings have been scheduled yet.
No. | Start day | End date | Place | Result |
---|---|---|---|---|
first | 8/8 | 8/11 | A | Create a successful meeting |
2 | 8/8 | 8/11 | B | The start date is invalid |
3 | 8/15 | 8/11 | A | The start date overlaps |
4 | 8/11 | 4/8 | A | End date is invalid |
5 | 8/8 | 8/16 | A | The end date overlaps |
2.2. Strong equivalence class test
Strong equivalence class testing will combine possible combinations of equivalent domains. Considering the assumption in section 2.1, here we will have 3 4 2 = 24 combinations, corresponding to 24 test cases as follows:
No. | a | b | c |
---|---|---|---|
first | a_1 | b_1 | c_1 |
2 | a_1 | b_1 | c_2 |
3 | a_1 | b_2 | c_1 |
4 | a_1 | b_2 | c_2 |
5 | a_1 | b_3 | c_1 |
6 | a_1 | b_3 | c_2 |
7 | a_1 | b_4 | c_1 |
8 | a_1 | b_4 | c_2 |
9 | a_2 | b_1 | c_1 |
ten | a_2 | b_1 | c_2 |
11 | a_2 | b_2 | c_1 |
twelfth | a_2 | b_2 | c_2 |
13 | a_2 | b_3 | c_1 |
14 | a_2 | b_3 | c_2 |
15 | a_2 | b_4 | c_1 |
16 | a_2 | b_4 | c_2 |
17 | a_3 | b_1 | c_1 |
18 | a_3 | b_1 | c_2 |
19 | a_3 | b_2 | c_1 |
20 | a_3 | b_2 | c_2 |
21 | a_3 | b_3 | c_1 |
22 | a_3 | b_3 | c_2 |
23 | a_3 | b_4 | c_1 |
24 | a_3 | b_4 | c_2 |
Here, we focus on the equivalent domains of the input variable. We can also apply this method to the output domain, but this is usually more difficult because we have to recalculate the set of test values in the input domain to create the value in the desired output domain.
- Consider the example in 2.1
Tests of the weak equivalence class are listed as in the following table:
No. | Start day | End date | Place | Expected results |
---|---|---|---|---|
first | 8/8 | 8/11 | A | Create a successful meeting |
2 | 8/8 | 8/16 | B | Create a successful meeting |
3 | 8/15 | 8/9 | B | Failed to create the meeting |
We find that this method is weak because it only gives a few test cases that are not reliable enough for the program.
2.3. Simple equivalence test class
The equivalence class test simply divides a class of valid values and an equivalent class of invalid values. Once equivalence classes are available in this simple way, the test strategy can be applied to strong and weak equivalence testing.
- Consider the example in section 2.1
According to the strong equivalent method, we have 2 3 3 = 18 combinations. Corresponding to 18 test cases
But in 18 test cases, there were 2 2 2 = 8 test cases that were duplicated and unnecessary. We then got a table of 10 test cases:
No. | Start day | End date | Place | Result |
---|---|---|---|---|
first | 8/8 | 8/11 | A | Create a successful meeting |
2 | 8/8 | 8/11 | B | Create a successful meeting |
3 | 8/8 | 4/8 | A | End date is invalid |
4 | 8/8 | 4/8 | B | End date is invalid |
5 | 8/8 | 8/16 | A | End date is invalid |
6 | 8/8 | 8/16 | B | Create a successful meeting |
7 | 8/8 | 8/11 | A | The start date is invalid |
8 | 8/8 | 8/11 | B | The start date is invalid |
9 | 8/15 | 8/11 | A | The start date is a duplicate |
ten | 8/15 | 8/16 | B | Create a successful meeting |
3. Advantages and Disadvantages of the technique
3.1. Advantages
Because each equivalent region we only need to test on representative elements, the number of test cases is greatly reduced, so that the test time is also significantly reduced.
3.2. Defect
Not all problems can apply this technique. A border error may be omitted if only the value in the middle of the equivalent domain is selected. So when most of the errors are found when checking the values at the boundary of the partitions, we should learn one more technique is to analyze the boundary value.