In the world of software testing, ensuring comprehensive coverage of test cases while maintaining efficiency is a critical challenge. Among the range of techniques available, Boundary Value Analysis (BVA) and Equivalence Partitioning (EP) stand out as fundamental methods that significantly enhance the effectiveness of test design. These techniques help identify critical test cases and ensure that the testing process is both systematic and thorough.
In this blog post, we will delve into the principles of BVA and EP, exploring how they can be applied to optimize testing efforts and improve software quality.
Both are black box testing techniques. Let’s start with an explanation of the Equivalence Partitioning technique.
✅ Equivalence Partitioning
The steps should be as follows:
- Divide the test conditions into groups or sets of partitions. All the elements under the same set of partitions are considered the same, and the system should handle them equivalently.
- A partition containing valid values is called a valid partition
- A partition containing invalid values is called an invalid partition
For non-numeric example:
If the fruits = apple, then print green
If the fruits = orange, then print the orange
In the above example, Apple and Orange are valid partitions, while no invalid partition is specified; we assumed other fruits are invalid partitions.
For numeric example :
Users should be able to register when they are between ages 1 and 21.
In the above example, an age between 1 and 21 is a valid partition(able to register), while an age between less than 1 and more than 21 is an invalid partition(unable to register).
2. When there are multiple sets of partitions or more than one input,
- The valid partition shall combined.
- The invalid partition should be tested individually.
Let’s take this as an example; the requirement is to register a user email when it hits the requirements below:
- It should be 6–30 characters long
- Should be alphanumeric
Following the No. 2 rules, we don't need to create 5 test cases for 3 partitions belonging to (6–30 characters long) and 2 partitions belonging to (should be alphanumeric).
We shall combine the valid partition and come out with the same test value (input) of abc123.
Then, to test the invalid partition individually.
In this example, 4 test cases are sufficient to test out all the combinations of partitions.
The question may arise: why don't we combine the invalid partition?
For example, if we test only with less than 6 characters, the error message is “Sorry, your username must be between 6 and 30 characters long”
However, when we tested the invalid partition of <6 characters and the invalid partition of not alphanumeric, the error message was “Sorry, only letters (a-z), numbers (0–9), and periods (.) are allowed.”
It’s clear that when we combine two invalid partitions to test, it’s very easy to miss out on validating the invalid partition of <6 characters. In this case, the test cases are not well designed.
✅ Boundary Value Analysis
Boundary value analysis is closely related to equivalence partitioning. We can determine the boundary value by knowing the partition.
We will use back the same numeric example:
- Users should be able to register when they are between ages 1 and 21
And we know that
- age between 1 and 21 is a valid partition (able to register),
- age less than 1 and more than 21 is an invalid partition (unable to register).
To determine what is the boundary values:
Rule 1: The BVA is that the minimum and maximum values of the partition are called the partition's boundary values.
Hence, the boundary values of (1 to 21) are 1 and 21.
Next, let's find out what the 2-value BVA or 3-value BVA are.
For 2-Value BVA: This boundary value and its closest neighbor belonging to the adjacent partition will be boundary values.
Boundary values of (1 to 21) are the values of 1 and 21.
(Adjacent partition) Boundary values of (1 to 21) are the values of 0 and 22.
Hence, the 2-value BVA are the values of 0, 1, 21, 22.
For 3-Value BVA: This boundary values and both their neighbors will be boundary values.
Boundary values of (1 to 21) are the values of 1 and 21.
(adjacent partition) Boundary values of (1 to 21) are the values of 0 and 22
Boundary values and both its neighbors of (1 to 21) are the values of 0, 1, 2, 20, 21, 22.
Boundary values and both its neighbors of (0 and 22) are the values of 1, 0, 1, 21, 22, 23.
Hence, the 3-value BVA are the values of -1, 0, 1, 2, 20, 21, 22, 23
Now, you may wonder when we should use 2-value BVA or 3-value BVA.
Let’s try another requirement:
- Users should be able to register when their age less or equal to 21
And somehow, developers make this mistake in the logic to be able to register when age = 21.
We may have overlooked and missed this bug because the 2-value BVA only tests 21; however, a 3-value BVA may be able to surface the issue because the value of 20 is tested.
Boundary Value Analysis and Equivalence Partitioning are useful techniques for any software tester. By focusing on critical edge cases and grouping inputs into meaningful categories, these techniques avoid exhaustive testing, streamline the testing process, and uncover potential defects that might otherwise go unnoticed. Embracing these methods will enhance your testing strategy and ensure that your applications meet the highest standards of quality and performance.
Top comments (0)