Welcome to this tutorial on understanding equivalence partitioning.
The goal of this tutorial is to guide you through the concept of Equivalence Partitioning, a software testing design technique that simplifies the testing effort.
By the end of this tutorial, you will have a clear understanding of:
This is a beginner-friendly tutorial. However, having some basic understanding of software testing would be helpful.
Equivalence Partitioning is a software testing technique that divides the input data of a software unit into partitions of equivalent data from which test cases can be derived.
In equivalence partitioning, inputs to the software or system are divided into groups that are expected to exhibit similar behavior, hence reducing the total number of test cases to be developed.
Think of a system that accepts age as an input field. The valid age range is 18-65. Any age below 18 and above 65 is considered invalid.
Here, we can create three equivalence classes:
Unfortunately, equivalence partitioning is a concept used in manual testing, and thus, does not have any code examples. However, it can be used in automated testing scenarios. Here's an example in Python using pytest:
import pytest
def test_age_group():
assert age_group(17) == 'Invalid'
assert age_group(18) == 'Adult'
assert age_group(65) == 'Adult'
assert age_group(66) == 'Invalid'
In the above example, we are testing an imaginary function age_group
, which should return 'Invalid' for ages below 18 and above 65, and 'Adult' for ages between 18 and 65.
In this tutorial, we have covered the concept of equivalence partitioning, a software testing technique that groups the input data of a software unit into partitions of equivalent data, from which test cases can be derived. We also looked at an example of how to apply this concept.
For further learning, explore boundary value analysis, which is similar to equivalence partitioning and often used together.
Now, let's put what we have learned into practice. Here are some exercises for you:
For a system that accepts a percentage as input, the equivalence classes would be:
For a login system that accepts a password with a length of 6-12 characters, the equivalence classes would be:
These exercises are aimed at helping you understand how to create equivalence classes. As a tip, remember to always include both valid and invalid classes when creating your partitions.