Testers employ boundary value analysis (a type of black box test design technique) in order to test the boundary conditions in a program.
Let’s look into an example where we need to use the BVA technique.
Example: Consider an input field which accepts integer values between 10 and 20 (inclusive).
As per the example specification, the input field should accept values which are greater than or equal to 10 and less than and equal to 20. Here the boundary values are 10 and 20. Any value less than 10 and greater than 20 shouldn’t be accepted. Also, proper error messages should be displayed or handled through exceptions.
In order to test the boundary conditions, we need to write test cases for the below values:
- 10 ———->ON the boundary
- 9 ———->OUTSIDE of the boundary
- 20 ———->ON the boundary
- 21 ———->OUTSIDE of the boundary
We can even include the IN condition. For example, the values 11 and 19 which is inside the boundary values.
From the above example, we can infer that boundary value analysis (BVA) is like an extension to Equivalence class partitioning. However, we will be concentrating more on the edge cases of those equivalence classes. In the given example, the equivalence classes are
- the range of input values 10 – 20 (valid equivalence class)
- input values < 10 (Invalid equivalence class)
- input values > 20 (Invalid equivalence class)
Rather than selecting any element in an equivalence class as being representative, boundary-value analysis requires that one or more elements be selected such that each edge of the equivalence class is the subject of a test.
Example: If an input file can contain 1–255 records, write test cases for 0, 1, 255, and 256 records.
“Bugs lurk in corners and congregate at boundaries.” Boris Beizer
Programmers often tend to make mistakes on the boundary conditions. Hence we need to focus testing more on these boundaries. BVA is an efficient test case design technique which helps testers to uncover these types of boundary errors.
Also, one important attribute of BVA technique is it works only on ordered partitions as explained above.
I’d like to mention an interesting Bug Report explained in the textbook “The Software Test Engineer’s Handbook, 2nd Edition”.This clearly shows the importance of Boundary Value Analysis technique in test case design.
Defect Report: You owe me $0
A bank issued a letter to a customer demanding payment for $0 (that was the first BVA problem). The customer ignored it until the bank threatened legal measures. The customer diligently submitted a check for $0, which promptly crashed the entire application (second BVA problem). The bank shall remain nameless.