- Computers & Software»
- Computer Science & Programming
Software Testing by Equivalence Partitioning
Equivalence Partitioning is a Blackbox Testing Technique. It makes use of the fact that the inputs and outputs of a component under test can be partitioned into classes. Values in the same class will be treated in the same way. So, the result of testing any value from a partition is considered to be representative of the whole partition.
For example, suppose an application collects some data about a traveller using the dialog box shown in the diagram. When the OK button is pressed the component calculates a fare from the current location using the input values.
The Discount Table
64 years and older
There is a standard fare to each destination. Our travel service offers discounts to travellers based on their age. For example, children under 5 travel free and those over 65 get a 25% discount.
There are possibly an infinite number of age values that could be input, it is impractical to test them all.
We can use equivalence partitioning to test the processing of data. We need to partition the possible age values into classes where all members should be treated in the same way. Using the Discount Table, we can see four partitions of valid ages and create two partitions of invalid ages:
0, 1, 2, 3, 4.
5, 6, 7, …15.
16, 17, 18, …64.
65, 66, 67, …120.
Ages greater than 120 years.
Ages containing non-numeric characters,
Equivalence partitioning requires us to choose one value from each partition. Where possible, a middle value is chosen. So we would test the processing of ages 2, 10, 40, 108, 555 and ‘one’. To complete equivalence partition testing we need only perform six tests.
The Fare Table
Another feature of our application is that fares are regional; fares to the same region are all the same.
The destination field can be partitioned into the same regions:
Manchester, Liverpool, Warrington.
Cardiff, Swansea, Newport.
To complete equivalence partition testing on the destination input field we choose one town from each region. For example: Liverpool, Glasgow and Cardiff.
The component handles all values in the name in the same way; it prints the name on any tickets that are issued. As all values are treated the same, it is not possible to separate the name field values for equivalence partitioning.