Boundary Value Analysis: A Complete Guide With Examples

boundary value analysis guide

Boundary value analysis (BVA) tests the values at and around the edges of each input range, where defects cluster. See 2-value vs 3-value BVA, worked examples for numbers, lengths, dates, and prices, and how to automate boundary tests.

Key takeaways
The 30-second version of this article
Boundary value analysis tests input values at, just below, and just above the edges of each range, because off-by-one errors and unclear range rules cluster at those edges.
2-value BVA tests each boundary and its nearest outside neighbor (4 tests for one range). 3-value BVA adds the nearest inside neighbor (6 tests) and catches more operator mistakes.
For an age field that accepts 18 to 60, 3-value BVA tests 17, 18, 19, 59, 60, and 61.
Use the smallest meaningful step for the data type: 1 for whole numbers, 1 character for text, 1 day for dates, and $0.01 for prices.
Run boundary values as a data-driven test and check them through the API as well as the UI, since a form limit does not stop a direct request.

Boundary value analysis (BVA) is a black-box test design technique that tests the values at, just below, and just above the edges of each input range. It works because defects cluster at those edges: a developer writes > instead of >=, a spec says "up to 64 characters" without saying whether 64 is allowed, or the UI limit and the API limit disagree. Testing a handful of edge values catches these faster than testing many values from the middle of a range.

BVA builds on equivalence class partitioning (ECP), so this guide starts with a quick ECP recap, then covers BVA, the 2-value and 3-value methods, worked examples for numbers, lengths, dates, and prices, and how to automate boundary tests.

What is equivalence class partitioning?

Black box testing technique: equivalence class testing

Equivalence Partitioning Testing is a black-box testing method that divides input data into equivalent sets. The idea is that if one condition in the group passes or fails, the entire group will behave similarly. This significantly reduces the number of test cases while ensuring adequate test coverage.

Suppose you're testing a function that validates a user's age for an online registration form, with a valid age range of 18 to 60 years.

Here’s how you could create equivalence classes:

  • Valid Equivalence Class: Ages 18 to 60 [18-60]
  • Invalid Equivalence Classes:
    • Ages less than 18: [-∞ to 17]
    • Ages greater than 60: [61 to ∞]
    • Non-numeric inputs: ["abc", "#$%", etc.]

Now, let's select representative values from each class:

  • Valid class: 25 (within the valid range)
  • Invalid classes:
    • Less than 18: 17
    • Greater than 60: 61
    • Non-numeric: “abc”

From these, we can generate the following test cases:

  1. Test Case 1: Age = 25 (Expected: Valid)
  2. Test Case 2: Age = 17 (Expected: Invalid)
  3. Test Case 3: Age = 61 (Expected: Invalid)
  4. Test Case 4: Age = "abc" (Expected: Invalid)

What is boundary value analysis?

Black box testing technique: boundary value analysis

Boundary Value Analysis is a black-box testing method that aims to test the boundaries between equivalence classes. While Equivalence Class Partitioning only divides inputs into valid and invalid groups, BVA takes this a step further by testing only extreme values just below, just above, and at the defined boundaries. This helps ensure the system properly handles edge cases, which are often where software failures occur.

Let's go back to the previous example. You're testing a function that validates a user's age, with a valid age range of 18 to 60 years. We have the following equivalence classes already defined:

  • Valid Equivalence Class: [18–60]
  • Invalid Equivalence Classes:
    • Ages less than 18: [-∞ to 17]
    • Ages greater than 60: [61 to ∞]
    • Non-numeric inputs: ["abc", "#$%", etc.]

Boundary value analysis focuses on testing the boundaries of these ranges.

  • Just outside the lower boundary: 17
  • At the lower boundary: 18
  • Just above the lower boundary: 19
  • Just below the upper boundary: 59
  • At the upper boundary: 60
  • Just outside the upper boundary: 61

You now have 6 critical test cases, which cover the key points where errors are likely to occur.

2-value vs 3-value boundary value analysis

There are two common ways to pick boundary values, and the ISTQB syllabus describes both.

  • 2-value BVA: for each boundary, test the boundary value itself and its closest neighbor on the other side of the boundary. For the 18 to 60 age range, that is 17 and 18 at the lower edge, and 60 and 61 at the upper edge: 4 test cases.
  • 3-value BVA: for each boundary, test the boundary value and both of its neighbors. That gives 17, 18, 19 at the lower edge and 59, 60, 61 at the upper edge: 6 test cases.

Method

Lower boundary values

Upper boundary values

Test cases

When to use it

2-value BVA

17, 18

60, 61

4

Most fields, when time is limited and the rule is a simple comparison

3-value BVA

17, 18, 19

59, 60, 61

6

Risky fields (payments, eligibility, limits), or when you suspect the comparison operator is wrong

3-value BVA costs two extra tests per field, but it catches a bug that 2-value BVA can miss: if the code checks age == 18 instead of age >= 18, the value 19 fails while 18 still passes.

Why boundary value analysis is important

Testing within the range of valid inputs alone may not reveal issues that occur at the system’s extremes. For example, if the form accepts ages from 18 to 60 but fails to handle edge cases like 17 or 61 correctly, users may encounter problems at these boundaries. BVA ensures these edge cases are properly tested.

Going beyond simple boundaries

Boundary value analysis doesn’t stop at obvious boundaries. Consider more extreme cases to ensure thorough coverage. For instance, what happens if someone enters an age of -3, 9,999,999, or a non-numeric value like “twenty-five”? Work with developers to understand how edge cases are handled in the code, so your boundaries are tested effectively.

Boundary value analysis examples

The age field is the classic example, but most boundary bugs show up in other kinds of input. Here are four more, each using 3-value BVA. The step size is the smallest meaningful change for that input: 1 for whole numbers, 1 character for text, 1 day for dates, and $0.01 for prices.

Example 1: Password length (8 to 64 characters)

Test value

Input

Expected result

Just below lower boundary

7 characters

Rejected, "Password must be at least 8 characters"

Lower boundary

8 characters

Accepted

Just above lower boundary

9 characters

Accepted

Just below upper boundary

63 characters

Accepted

Upper boundary

64 characters

Accepted

Just above upper boundary

65 characters

Rejected, or blocked from typing past 64

Test the 65-character case through the API as well as the UI. A maxlength attribute on the form stops typing, but it does not stop a request sent straight to the backend.

Example 2: Cart quantity (1 to 99)

Test value

Input

Expected result

Just below lower boundary

0

Rejected, or item removed from cart

Lower boundary

1

Accepted

Just above lower boundary

2

Accepted

Just below upper boundary

98

Accepted

Upper boundary

99

Accepted

Just above upper boundary

100

Rejected with a clear message

Example 3: Minimum order for a discount ($50.00)

Prices are decimals, so the step is one cent, not one dollar.

Test value

Order total

Expected result

Just below boundary

$49.99

Discount not applied

Boundary

$50.00

Discount applied

Just above boundary

$50.01

Discount applied

Also check how the total is calculated before the comparison. If tax, shipping, or currency rounding is applied first, a cart worth $49.995 might round up and qualify.

Example 4: Booking date (today to 365 days ahead)

Test value

Date

Expected result

Just below lower boundary

Yesterday

Rejected

Lower boundary

Today

Accepted

Just above lower boundary

Tomorrow

Accepted

Just below upper boundary

Today + 364 days

Accepted

Upper boundary

Today + 365 days

Accepted

Just above upper boundary

Today + 366 days

Rejected

Run the date cases near midnight and across time zones too. "Today" on the server is not always "today" for the user.

Bugs boundary value analysis catches

These are the defects that boundary tests find most often:

  • Off-by-one errors: > used where >= was intended, or a loop that stops one item early.
  • Inclusive vs exclusive ranges: the spec says "between 18 and 60" and nobody agreed whether 18 and 60 are allowed.
  • UI and API mismatch: the form enforces a limit that the API does not, or the other way around.
  • Overflow: a value larger than the data type can hold, such as anything above 2,147,483,647 in a signed 32-bit integer.
  • Rounding: decimal values that round across a boundary before the check runs.
  • Hidden transformations: trimming whitespace or normalizing text changes the length after validation.

Limitations of boundary value analysis

BVA is efficient, but it does not cover everything:

  • It assumes the input has ordered ranges. It adds little for unordered choices such as a country list.
  • It tests one input at a time. When the rule depends on a combination of inputs, for example a limit that changes by account type, pair it with decision table testing.
  • It finds edge defects, not logic errors in the middle of a range. Keep a few representative values from equivalence partitioning as well.

Boundary value analysis best practices

Here are some best practices to follow when performing Boundary Value Analysis:

1. Identify equivalence classes

Begin by identifying the valid and invalid input ranges for your system. For instance, in the age validation example, the valid class is [18-60], and the invalid classes are those above 60, below 18, or non-numeric inputs.

2. Determine boundaries

Once the equivalence classes are established, determine the boundaries for each class. For the age validation example, boundaries include 17, 18, 19, 59, 60, and 61.

3. Select test cases

Choose values that are at, just below, and just above each boundary. This ensures that edge cases are covered, where errors are most likely to occur.

How to choose values above and below boundaries

When selecting values for boundary testing, consider how far above or below the boundary you should test. For example, if your input range is divided into multiple segments (e.g., [0-30], [31-60], [61-90]), selecting a value just above the boundary at 30 might mean crossing into the next range. Ensure that your selected boundary values are meaningful and within the context of the system.

Boundary value analysis vs equivalence partitioning

While Equivalence Class Partitioning (ECP) focuses on grouping inputs into valid and invalid sets, Boundary Value Analysis takes this a step further by concentrating on the "edge" or boundary points of those sets. In a way, BVA is ECP taken to a more granular level. Testing just a few values at the edges often reveals more errors than testing random values within the middle of a class.

How to automate boundary value tests

Boundary tests are a natural fit for data-driven testing: the test logic stays the same and only the input and expected result change. Keep the boundary values in a table, and run one test per row.

import pytest
from registration import is_valid_age

@pytest.mark.parametrize("age, expected", [
    (17, False), (18, True), (19, True),
    (59, True), (60, True), (61, False),
])
def test_age_boundaries(age, expected):
    assert is_valid_age(age) == expected

The same pattern works in most frameworks. In Katalon Studio, you bind a data file to a test case so each row runs as its own iteration. See data-driven testing in Katalon Studio for the setup.

When a requirement changes, for example the maximum age moves from 60 to 65, you update one row of data instead of rewriting tests.

Summary

Boundary value analysis targets the values where input rules change, because that is where defects cluster. Start from your equivalence classes, pick 2-value or 3-value boundaries based on risk, use the right step size for the data type, and test through the API as well as the UI. A short table of boundary values, run as a data-driven test, gives you strong coverage for very few test cases.

Frequently asked questions

Henrik (Minh Huy) Dao

Minh Huy Dao (Henrik) is a Senior Quality Engineer at Katalon, where he has worked since 2023. He has nearly 10 years of experience in QA and test automation, including roles at TMA Solutions, Axon Active and Doctor Anywhere. His work spans automation with Java, JavaScript and WebdriverIO, as well as CI/CD with Jenkins and leading Scrum teams.

Connect on LinkedIn →
Get started

Test everything. Ship with confidence.

From generating test cases to spotting failures, Katalon's AI works across your entire pipeline, automatically.

Live webinar

The Next Evolution of Manual Testing: Introducing Katalon AI Test Runner

Learn how to grow your QA team's capacity in the age of AI, then watch Katalon AI Test Runner turn manual test cases into automated runs, live.

2:00 to 3:00 PM IST
Almas AhmedSenior Account Manager
Sumit WankhedeSolutions Engineer Manager
Register now