Boundary Value Analysis & Equivalence Partitioning with Examples
Boundary value analysis and equivalence partitioning are two techniques that can be used to design effective and efficient test cases for a software application.
Boundary value analysis involves testing values that are at the edge or boundary of the input domain. For example, if a field accepts numeric input in the range of 1 to 100, the boundary values would be 1, 100, and all values in between. Testing these boundary values can help identify defects that occur at the edges of the input domain.
For example, consider a field that accepts a person’s age, with a minimum value of 18 and a maximum value of 120. Using boundary value analysis, the following test cases could be designed:
- Input: 17 (invalid, below minimum)
- Expected result: Error message stating that the age must be at least 18
- Input: 18 (valid)
- Expected result: Accepted
- Input: 19 (valid)
- Expected result: Accepted
- Input: 119 (valid)
- Expected result: Accepted
- Input: 120 (valid)
- Expected result: Accepted
- Input: 121 (invalid, above maximum)
- Expected result: Error message stating that the age must be at most 120
Equivalence partitioning involves dividing the input domain into equivalence classes, where each class represents a group of input values that can be expected to behave in the same way. For example, if a field accepts alphabetic input, the input domain can be partitioned into three classes: uppercase letters, lowercase letters, and non-alphabetic characters. Testing a representative value from each class can help ensure that the application is handling all valid and invalid input values correctly.
For example, consider a field that accepts a person’s gender, which can be either “male”, “female”, or “other”. Using equivalence partitioning, the following test cases could be designed:
- Input: “male” (valid)
- Expected result: Accepted
- Input: “female” (valid)
- Expected result: Accepted
- Input: “other” (valid)
- Expected result: Accepted
- Input: “Male” (invalid, wrong case)
- Expected result: Error message stating that the gender must be “male”, “female”, or “other”
- Input: “m” (invalid, not a full word)
- Expected result: Error message stating that the gender must be “male”, “female”, or “other”
- Input: “f” (invalid, not a full word)
- Expected result: Error message stating that the gender must be “male”, “female”, or “other”