How To Write Your Test Cases, Part 5 (Equivalencies)

Equivalence partitioning

Equivalence partitioning is one of the software testing methodologies that you just have to know. It can reduce your workload by a huge amount and make you a more efficient tester. Essentially, it is a term for saying that a1 = a2 = a3 etc, etc, so that if you have tested a1, then you have also tested a2, a3, a4, etc, etc.

Say you are testing that the totalling functionality on an e-commerce website is working correctly, then calculating the total of purchases at £10, £11, and £12 is essentially the same as calculating the total of purchases at £15, £16, and £17. The functionality is supposed to add up the numbers and give the correct total.

How many permutations of numbers are there? It is an infinite amount, and so you cannot possibly expect to go through all of them and make sure that the amount calculated is always correct.

But you can say that it is basically a calculator function, and that if it adds up one set of numbers correctly, it will add up another set of numbers correctly. In essence, when you say this, you are saying that if it can add up 10, 11, and 12 correctly, then it can also add up 15, 16, and 17 correctly. That means that each of those tests is essentially the same, or that they are equivalents.

Another example is that you are testing a limit on a credit card. Supposing that the card will allow credit purchases up to £1000 in value. Clearly, a purchase of £2000 should be rejected. So should a purchase of £1001. A purchase which takes the value to more than £1000 should also be rejected. So if you are starting from, say, an existing balance of £995, then any amount which takes it over £1000 should be rejected, whether it is £5.01 or £10,000. This would be true of any amount inbetween, and also of any amount above £10,000. So in that respect, any amount of £5.01 or greater should produce the same result - in testing terms, they are equivalent.

With this example, you can also see that equivalence partitioning can be closely linked to boundary testing, because anything that falls outside the boundary is equivalent, regardless of it's value.

Hopefully you can see from these examples that as a tester, this is one of the types of testing techniques that you will find extremely useful.