Boundary Value Analysis

Boundary Value Analysis

Boundaries are very important for testing point of view. The errors normally occur at boundaries. Even for products of daily usage, we do test the boundary. For instance, when we buy a car we check its boundary of maximum mileage for one liter of petrol.

Boundary value analysis is continuation of the concept of equivalent class partitioning. For any range of possible inputs, we first define equivalent classes and then for every class we mark the boundaries and write test cases for each boundary.

Example 1

Say we have the following scenario for an input field.

0 — 500 Novice Player in Chess

500 – 1000 A Chess Player with Basic Skills

1000 – 2000 An Experienced Chess Player

Now, actually we have total 2000 possible inputs from 0 – 2000. Nevertheless, at the first step, we can divide this input space into equivalent classes. According to the concept of equivalent class partitioning, we have five classes, hence five test cases, choosing input from each class.

  1. Below 0
  2. Between 0 and 500
  3. Between 500 and 1000
  4. Between 1000 and 2000
  5. Above 2000

In boundary value analysis, we figure out the boundary for each class and write test cases. For each boundary, we write three test cases, one exactly at the boundary, one just below the boundary and one just above the boundary.

In above example, we have 4 boundaries, 0, 500, 1000, 2000 and there will be three test cases for each boundary totaling 12. For instance at boundary 500, we will test at 500-1, at 500 and at 500+1

Id Input Expected output
1 -1 NA
2 0
3 1 Novice Player in Chess
4 499 Novice Player in Chess
5 500
6 501 A Chess Player with Basic Skills
7 999 A Chess Player with Basic Skills
8 1000
9 1001 An Experienced Chess Player
10 1999 An Experienced Chess Player
11 2000
12 2001 NA

Note, the adding and subtracting at boundary value really depends upon the type of value. If the boundary is whole number, we add and subtract 1 and if the boundary has some other type, we adjust the value accordingly. For instance if the boundary is 500.35, the value just above the boundary would be 500.36 and the value just below the boundary would be 500.34

Example 2

Write test cases using boundary value analysis for the following paragraph.

“A savings account in a bank has a different rate of interest depending on the balance in the account. In order to test the software that calculates the interest due, identify the ranges of balance values that earn the different rates of interest. For example, 3% rate of interest is given if the balance in the account is in the range of $0 to $100, 5% rate of interest is given if the balance in the account is in the range of $100 to $1000, and 7% rate of interest is given if the balance in the account is $1000 and above.”

First, we identify equivalence classes.

Less than 0. Not Applicable

Between 0 and 100 3%

Between 100 and 1000 5%

Above and equal to 1000% 7%

Hence, the boundaries are 0, 100 and 1000% and the test cases are as follows

Id Input Expected output Actual output Status
1 -1 NA
2 0
3 1 3%
4 99 3%
5 100
6 101 5%
7 999 5%
8 1000
9 1001 7%

Using boundary value analysis in requirement specifications.

We should start testing as soon as possible even before coding. It enhances quality at every phase of the development. If we do boundary value analysis at requirement gathering phase, we can point out many ambiguities of the requirements.

In first example, we are not sure about the output of the boundary values of 0, 500, 1000, 2000 as these values lie in both classes. Similarly, in second example we do not know about the output of the boundaries 0, 100, 1000. In such cases, we contact the client and clarify the exact output for the boundary values. After clarification from the client, the requirement for the first example might be as below.

=0 and < 500 Novice Player in Chess

>=500 and <1000 A Chess Player with Basic Skills

>=1000 and <2000 An Experienced Chess Player

And the requirement for example 2 may be.

<0. Not Applicable

>= 0 and <100 3%

>=100 and <1000 5%

>=1000% 7%