Published on
· July 10, 2026

Boundary Value Analysis: What It Is and How to Apply It in Testing

Blog
  • Photo of Henrico Piubello
    Henrico Piubello
    Henrico Piubello
    IT Specialist - Grupo Voitto

    IT Specialist - Grupo Voitto

Illustration of minimum and maximum boundary values in software testing

Boundary Value Analysis (BVA) is a black-box software testing technique that checks the extremes of input partitions — minimum, maximum and their immediate neighbors — used to detect defects that concentrate at the edges of the intervals a program accepts.

What is boundary value analysis?

Boundary value analysis is a black-box testing technique that derives test cases from values located at the boundaries of input partitions: the smallest accepted value, the largest accepted value and the values immediately outside that interval. It is also called boundary testing or edge testing.

The technique starts from a practical observation: the most critical errors tend to occur when input data approaches the limits of what a program can handle — day 31 of a month, the maximum value of a transaction, the final index of an array. Conditions like > written instead of >= go unnoticed in central values but fail exactly at the edge.

Because of that, boundary value analysis is usually applied as an extension of equivalence partitioning: first, the input domain is divided into partitions with equivalent expected behavior; then, the boundaries between those partitions are tested, rather than random values in the middle of each one.

Why test boundary values?

Testing boundary values concentrates testing effort where the probability of defects is highest, reducing the cost of finding critical bugs before production. The economic impact of not doing this is well documented.

The study The Economic Impacts of Inadequate Infrastructure for Software Testing, published by NIST (National Institute of Standards and Technology) in 2002, estimated that software defects cost the US economy 59.5billionperyearabout0.659.5 billion per year — about 0.6% of GDP at the time — and that approximately 22.2 billion could be eliminated with better testing infrastructure and earlier error identification.

The problem has only grown: the Cost of Poor Software Quality in the US: A 2022 Report, by CISQ (Consortium for Information & Software Quality), estimated the cost of poor software quality in the US at least 2.41trillionin2022,withaccumulatedtechnicaldebtofabout2.41 trillion in 2022, with accumulated technical debt of about 1.52 trillion.

In this scenario, boundary value analysis delivers three direct benefits within a software testing strategy:

  • Critical bug identification: boundaries concentrate comparison, overflow and validation errors.
  • Quality improvement: the software is verified in extreme situations, not just in the happy path.
  • Time and resource savings: a few well-chosen values cover more risk than many random values.

How do 2-value BVA and 3-value BVA work?

The ISTQB CTFL v4.0 syllabus, from ISTQB (International Software Testing Qualifications Board), defines two variants of the technique: 2-value BVA, which tests each boundary and the immediate neighbor of the adjacent partition, and 3-value BVA, which tests each boundary and the neighbors on both sides. The choice depends on the risk of the system under test.

Criterion2-value BVA3-value BVA
Values per boundaryThe boundary and the neighbor of the other partitionThe boundary and the neighbors on both sides
Example (boundary 18)Tests 17 and 18Tests 17, 18 and 19
Total in one interval4 test values6 test values
RigorSufficient for most systemsMore complete, detects additional defects
When to useCommon-risk systemsCritical, financial, security systems

A concrete example: if a field accepts ages 18 to 65, 2-value BVA tests 17, 18, 65 and 66; 3-value BVA adds 19 and 64. The official ISTQB white paper on Boundary Value Analysis details the coverage items of each variant and recommends the 3-value version when the consequences of a boundary defect are severe.

How to apply boundary value analysis in 5 steps?

Applying boundary value analysis follows a short, repeatable flow that works for both manual and automated tests:

  1. Identify the boundary values relevant to the system: upper and lower limits of numeric intervals, dates, monetary values, field sizes and collection indexes.
  2. Create test cases focused on those boundaries and their neighbors. In a financial application, for example, test values at the maximum transaction limit, immediately below and immediately above.
  3. Execute the tests covering all mapped values, record results and watch for any abnormal behavior, unexpected error messages or silent failures.
  4. Fix and repeat: when you find defects, adjust the code and re-run the cases until all boundaries are handled correctly.
  5. Automate whenever possible, incorporating boundary cases into the regression suite to ensure consistent coverage on every code change.

Practical example of boundary value analysis in code

The classic boundary value example is division: a denominator of 0 is the exact edge between valid and invalid inputs, and that is where the program breaks if there is no handling. Below, the same case in four languages.

Example in C

Using the C programming language:

#include <stdio.h>
#include <stdbool.h>

// Function to divide two integers
double divide(int numerator, int denominator) {
    if (denominator == 0) {
        // Avoid division by zero
        return -1.0; // Error value
    }
    return (double)numerator / denominator;
}

int main() {
    // Testing the divide function with boundary value analysis
    int testCases[5][2] = {
        {10, 2},    // Valid test
        {5, 0},     // Division by zero error
        {0, 0},     // Division by zero error
        {-7, 3},    // Valid test
        {100, 50}   // Valid test
    };

    for (int i = 0; i < 5; i++) {
        int numerator = testCases[i][0];
        int denominator = testCases[i][1];

        printf("Test %d: ", i + 1);

        if (numerator == 0 || denominator == 0) {
            printf("Division by zero error.\n");
        } else {
            double result = divide(numerator, denominator);
            printf("%d / %d = %.2f\n", numerator, denominator, result);
        }
    }

    return 0;
}

In this code, the divide function accepts two integers, numerator and denominator, and returns the division result. The function checks if denominator is zero — the boundary value — to prevent a division by zero, returning an error value (-1.0) in that case.

The test cases cover the boundary and both its sides:

  • Test 1: valid division (10 / 2 = 5.00)
  • Test 2: division by zero error
  • Test 3: division by zero error
  • Test 4: valid division (-7 / 3 = -2.33)
  • Test 5: valid division (100 / 50 = 2.00)

Example in Java

In Java, the boundary value is handled by throwing an ArithmeticException:

public class DivideExample {
    public static double divide(int numerator, int denominator) {
        if (denominator == 0) {
            throw new ArithmeticException("Division by zero error");
        }
        return (double) numerator / denominator;
    }

    public static void main(String[] args) {
        int[] numerators = {10, 5, 0, -7, 100};
        int[] denominators = {2, 0, 0, 3, 50};

        for (int i = 0; i < numerators.length; i++) {
            int numerator = numerators[i];
            int denominator = denominators[i];
            try {
                double result = divide(numerator, denominator);
                System.out.println("Result: " + numerator + " / " + denominator + " = " + result);
            } catch (ArithmeticException e) {
                System.out.println(e.getMessage());
            }
        }
    }
}

Example in JavaScript

In JavaScript, the same pattern uses throw and try/catch:

function divide(numerator, denominator) {
  if (denominator === 0) {
    throw new Error('Division by zero error')
  }
  return numerator / denominator
}

const numerators = [10, 5, 0, -7, 100]
const denominators = [2, 0, 0, 3, 50]

for (let i = 0; i < numerators.length; i++) {
  const numerator = numerators[i]
  const denominator = denominators[i]
  try {
    const result = divide(numerator, denominator)
    console.log(`Result: ${numerator} / ${denominator} = ${result}`)
  } catch (error) {
    console.log(error.message)
  }
}

Example in Python

Using the Python programming language:

def divide(numerator, denominator):
    if denominator == 0:
        raise ZeroDivisionError("Division by zero error")
    return numerator / denominator

numerators = [10, 5, 0, -7, 100]
denominators = [2, 0, 0, 3, 50]

for i in range(len(numerators)):
    numerator = numerators[i]
    denominator = denominators[i]
    try:
        result = divide(numerator, denominator)
        print(f"Result: {numerator} / {denominator} = {result}")
    except ZeroDivisionError as e:
        print(e)

Conclusion

Boundary value analysis is one of the best cost-benefit techniques in software testing: with half a dozen well-chosen values per interval, it captures the defect class that most often escapes to production — edge errors. Here at CodeCrush, the practical recommendation is straightforward: never use BVA as the sole method, but treat it as a mandatory item of any test suite, alongside equivalence partitioning, and automate boundary cases so every code change keeps being verified exactly where the software tends to break.

## faq

Frequently asked questions

What is boundary value analysis for?

Boundary value analysis is used to find defects that concentrate at the edges of a program input intervals, such as the minimum and maximum accepted. It reduces the number of test cases needed by prioritizing the values most likely to fail, and complements equivalence partitioning in black-box testing.

What is the difference between 2-value BVA and 3-value BVA?

In 2-value BVA, the boundary and the immediate neighbor of the adjacent partition are tested. In 3-value BVA, the boundary and the neighbors on both sides are tested. According to the ISTQB CTFL v4.0 syllabus, the 3-value version is more rigorous and indicated for critical systems, such as financial ones.

Is boundary value analysis a black-box or white-box testing technique?

Boundary value analysis is a black-box testing technique: test cases are derived from the specification of inputs and outputs, without inspecting the source code. It is usually applied together with equivalence partitioning, which divides inputs into groups with equivalent expected behavior.

Is it worth automating boundary value tests?

Yes. Boundary value tests are deterministic and repetitive, which makes them ideal for automation in frameworks like JUnit, pytest or Jest. Automating them ensures the boundaries remain covered on every code change, preventing regressions at interval edges, where the most critical defects tend to appear.

How many test cases does boundary value analysis generate?

It depends on the variant. For an interval with two boundaries, 2-value BVA generates four test values and 3-value BVA generates six, according to the ISTQB CTFL v4.0 syllabus. In practice, redundant values between neighboring partitions can be combined, reducing the total of executed cases.

Topics in this article

## continue lendo

Keep browsing

About the author

Photo of Henrico Piubello

Henrico Piubello

IT Specialist - Grupo Voitto · Grupo Voitto

See profile and all articles