Software Testing | Boundary Value Analysis: Explained with Examples

 
Boundary Value Analysis: Explained, explaining the topic, easy to understand

In this article, we are going to explore the term 'Boundary Level Analysis,' what the boundary is itself, and the concept of equivalence partitioning in software testing. Sometimes in testing the accuracy is what you need, because a little error can lead to some missed areas and further troubles.

Boundary value

To understand the concept, let's start with a boundary value element. A boundary value refers to an input or an output value that is either right at the limit of an interval (edge) or either just inside or just outside the interval.

It is usually where the software's behavior might change. This statement can be imagined in every system that accepts the values from x to y.

Example the boundaries:

The first  - lower boundary value is x.
The value just below the lower boundary is x - 1.
The second   - upper boundary value is y.
The value that is outside of the interval or above the upper boundary is y + 1.

We can imagine it in the exact case. Only a specific group of the university students have a discount to the online bookstore - the students between 18 to 26. If you are above 26, you are assumed not to be an university student, same goes for if you are below 18.

Applying this to your scenario of offering a discount to university students aged between 18 to 26 years old, the boundary values for testing would be:

  • 17 years old: Just below the lower boundary (18). High school students are not eligible for the discount.

  • 18 years old: The lower boundary. The discount starts from 18 years old students.

  • 26 years old: The upper boundary. The 26 years old students are the last who can use the discount.

  • 27 years old: Just above the upper boundary (26). 27 years old customers are not considered students anymore. The discount does not apply for them.

A control question - Are 22 years old students eligible for the online discount?
Yes, they are as the 22 years old students are in the valid range (18-26).

 

Boundary value analysis

It is important to understand the boundaries for a software testing technique called Boundary Value Analysis. It is a black-box test technique in which test cases are designed based on boundary values.

Boundary Value Analysis focuses on the values at or near the edge of the interval, including the values just inside and just outside these boundaries. It is assumed that the errors often happen at the borders of interval, as during the development the exact rules of the interval can get loose.

Using BVA there are two approaches — testing two boundaries (x and y) or testing three boundaries (x, x+1, y-1, and y) . Both of them are considered valid, but let’s have a look how they differentiate.

Testing Two Boundaries  (Minimal Approach):

  • At Lower Boundary (x): The exact lower limit of the valid range.

  • Just Below Lower Boundary (x-1): One unit below the lower limit.

  • At Upper Boundary (y): The exact upper limit of the valid range.

  • Just Above Upper Boundary (y+1): One unit above the upper limit.

This approach focuses on the exact edges and immediately outside the valid range. It is often used when the goal is to test the system’s handling inputs at the defined edges, or if for time reasons, you cannot do the longer version. 

Testing Three Boundaries (More Comprehensive Approach):

  • Just Below Lower Boundary (x-1): One unit below the lower limit.

  • At Lower Boundary (x): The exact lower limit of the valid range.

  • Just Above Lower Boundary (x+1): One unit above the lower limit.

  • Just Below Upper Boundary (y-1): One unit below the upper limit.

  • At Upper Boundary (y): The exact upper limit of the valid range.

  • Just Above Upper Boundary (y+1): One unit above the upper limit.

This prolonged approach tests not only the edges and their outside values but also the values just inside the valid range. It's used for more thorough testing, especially when the system's behavior near the boundaries is critical and you already predict there might be problems. You can also choose this approach when you have an extended period of time for testing. It is only good to test that the values inside of the valid range work.

Both approaches are correct within the context of BVA. The choice between two or three boundaries depends on the specific requirements and goals of your testing scenario. The minimal approach is often sufficient, but the more comprehensive approach can provide additional assurance.

Why Boundary Value Analysis?

Efficiency: By targeting possibly problematic values, the number of test cases can be reduced. In some cases, it is not necessary to test every value, just the boundary ones. Creating useful values for tailored test scenarios is also a plus.

Effectiveness: Concentrating on boundaries, which usually cause problems, makes the likelihood of finding bugs higher.

Simplicity: If you concentrate on boundaries, plus the values around them, you can develop a habit that simplifies the testing process.

 

BVA test scenario

Let’s create a Boundary Value Analysis (BVA) test scenario for a system that validates Swedish mobile numbers. Swedish numbers are between 8 to 10 digits long.


Test Scenario: Validation of Swedish Mobile Number Length in a Form.

Objective: To ensure that the system correctly accepts mobile numbers with a length of 8 to 10 digits and rejects numbers outside this range.

Here is a table representing the test cases following the BVA approach:

mobile-numbers-BVA-test-scenario-robinaAI-robina-ai-test-sceanrio-test-cases

Example test data for each test case:

  • TCA1 (7 - digit number): 1111111

  • TCA2 (8 - digit number): 11111111

  • TCA3 (9 - digit number): 111111111

  • TCA4 (10 - digit number): 1111111111

  • TCA5 (11 - digit number): 11111111111

Test Execution: 

For each test case, the ‘Mobile Number Input’ will be entered into the system. The response will be checked to see if it matches the ‘Expected Result’.

Expected Outcomes:

  • TCA1 and TCA5 should result in the system indicating that the input number is not valid (e.g., through an error message).

  • TCA2, TCA3, and TCA4 should be accepted as valid inputs without any error message.

This test scenario effectively utilizes BVA to ensure that the system accurately validates the length of Swedish mobile numbers, addressing the critical boundary points and their immediate neighbors.

You might also like…

 

Equivalence Partitioning

Covering the topic of Boundary Value Analysis, it is also crucial to mention Equivalence Partitioning as another fundamental testing technique very similar to BVA. As we talked about earlier, Boundary Value Analysis focuses on the edges of input ranges. The Equivalence Partitioning technique, on the other hand, divides input data into groups, otherwise called partitions.

These partitions are then expected to have the same behavior and will be treated similarly, if not the same, by the tested system. Test cases for this technique are designed to cover each partition at least once, making sure that every partition of inputs has been tested.

For example, given a university student website page that accepts student housing applications with input ages between 18 and 26. Using the Equivalence Partitioning technique, we will create test cases for valid age groups (18–26) and invalid age groups (below 18 and above 26). This approach then reduces the number of test cases we will need to create, but still ensures that one representative value from each partition is tested, what are in this case, high school students, university students, and possibly the non-students.

 
 
 
 
  • A black-box Software Testing technique in which test cases are designed based on boundary values.

  • A boundary value refers to an input or an output value that is either right at the limit of an interval (edge) or either just inside or just outside the interval.

  • Partition refers to a subset of input data or test conditions that are grouped together because they are expected to be treated similarly by the system being tested.

 
Previous
Previous

The One about Returning … After a Break or Vacation.

Next
Next

Responsibility in Quality