Skip to content
QAcademy — QAcademy

Test fundamentals ·

Boundary Value Analysis: Step-by-Step Method and Pitfalls

By The QAcademy team

Illustration for the article "Boundary Value Analysis: Step-by-Step Method and Pitfalls"

You tested "100" and "1,000" in the amount field, everything passes, you ship. The day a customer types exactly 500, the application treats it as a large claim when the rule says otherwise. Defects rarely hide in the middle of a range: they live on its edges.

In this article you will learn a four-step method for applying boundary value analysis, see what each variant costs and catches, spot the classic pitfalls and turn the values you find into automated tests.

Boundary value analysis: the idea in two minutes

Boundary value analysis (BVA) is a black-box test design technique. It starts from a simple observation: a badly written comparison (< instead of <=, a boundary off by one) only shows up at the border between two behaviours. Instead of picking random values inside a range, you test the values right on either side of the border.

It builds on equivalence partitioning: first split the domain into groups of values that should be handled the same way, then test the edges of each group. So it only applies to ordered data (numbers, dates, durations, text lengths), never to an unordered list such as a contract type.

An illustrative scenario: automatic refunds

Imagine a fictional claims management application with this rule in a user story:

A refund is approved automatically up to and including 500. Above that, it goes to manual review. Amounts are entered with two decimals. A zero or negative amount is rejected.

Three partitions appear:

Partition Values Expected behaviour
P1 amount ≤ 0 input rejected
P2 0.01 to 500.00 automatic approval
P3 amount > 500.00 manual review

The 4-step method

Step 1: list the ordered partitions

Go through the specification and note every piece of data whose behaviour changes with its value. Here there is one field, but a real form often has ten. Write the partitions like the table above: they give you the boundaries.

Step 2: identify the boundary values

For each partition, note its minimum and maximum:

  • P1: maximum 0.00 (the minimum is unbounded; if the application enforces a minimum input, that is another limit);
  • P2: minimum 0.01, maximum 500.00;
  • P3: minimum 500.01 (the maximum is not bounded in the specification).

Notice that last sentence: a specification that says nothing about the maximum is itself a test result. What happens with 999,999,999.99? Ask before you write the first case.

Step 3: choose 2 or 3 values per boundary

Two variants are commonly described, including in the ISTQB® Foundation syllabus:

  • 2-value: the boundary value and its neighbour in the adjacent partition. For the 500 border: 500.00 and 500.01;
  • 3-value: the boundary value and both neighbours. For 500: 499.99, 500.00 and 500.01.
2-value 3-value
Number of cases fewer about 50% more
Catches < instead of <= yes yes
Catches == instead of >= sometimes not yes
When to use tight deadline, low risk critical logic (money, rights, security)

The trap with the 2-value variant: if the code checks amount == 500 instead of amount <= 500, then 500.00 and 500.01 behave as expected by luck. Only a value further inside the partition (499.99) exposes the error. For a financial rule, take 3 values.

Step 4: write the cases with their expected result

Case Amount entered Expected result
TC1 -0.01 rejected
TC2 0.00 rejected
TC3 0.01 automatic
TC4 0.02 automatic
TC5 499.99 automatic
TC6 500.00 automatic
TC7 500.01 manual

Seven cases, each justified by a specific border. To write readable test cases, keep that "expected result" column: without it the team cannot tell whether a deviation is a defect or an omission.

The pitfalls that keep coming back

The ambiguous boundary

"Up to 500", "under 500", "between 10 and 500": these phrasings leave doubt about whether the boundary belongs to the range. Settling it is the most profitable decision in the whole design: ask the Product Owner to decide and add a numeric example to the user story.

Granularity

The "neighbour" of 500 is not always 501. With two-decimal amounts it is 500.01; with integers, 501; with a duration in seconds, 500 s + 1 s. Take the wrong step and you test a value too far from the border. Check the real precision of the data, in the UI and in the API.

Floating-point numbers

In most languages, floating-point numbers cannot represent 0.1 or 500.01 exactly. If the application compares amounts using such numbers rather than integer cents or a decimal type, a value sitting exactly on the boundary can fall on the wrong side. This is a very real source of defects around money: test boundary values end to end, from input to result, not only in the calculation function.

Limits that are not in the specification

A limit can come from elsewhere: a database column size, an API field length, a cap set by a payment provider. Review technical constraints as well as business rules.

Multiple limits and dates

When several limits interact (amount and customer seniority, say), test each limit while keeping the other values in the middle of their partitions, then add a few risky combinations. For dates, think about daylight saving changes, time zones and month ends: a "midnight" boundary is not the same in the server's time zone and in the browser's.

Automating boundary values (TypeScript)

The cases in the table lend themselves well to parameterised tests. Example with Vitest, on a fictional decideRefund function that works in cents to avoid rounding errors:

import { describe, expect, test } from "vitest";
import { decideRefund } from "./refund"; // fictional function for this example

// Amounts are expressed in cents (integers): 500.00 = 50000
describe("refund decision: boundary values", () => {
  test.each([
    { cents: -1, expected: "refused" }, // just below the lower limit
    { cents: 0, expected: "refused" }, // maximum of P1
    { cents: 1, expected: "auto" }, // minimum of P2 (0.01)
    { cents: 2, expected: "auto" }, // inner neighbour
    { cents: 49999, expected: "auto" }, // 499.99
    { cents: 50000, expected: "auto" }, // 500.00: the boundary
    { cents: 50001, expected: "manual" }, // 500.01: minimum of P3
  ])("$cents cents → $expected", ({ cents, expected }) => {
    expect(decideRefund(cents)).toBe(expected);
  });
});

One data table, one test: adding a limit you discover later costs one line. This kind of test also belongs in your regression testing strategy: boundaries are exactly what a refactoring breaks silently.

Key takeaways

  • BVA tests the values on either side of each border, because comparison errors live there.
  • It only applies to ordered data, after splitting into partitions.
  • For a critical rule, take 3 values per boundary: 2 values can let an == instead of >= slip through.
  • Frequent pitfalls: ambiguous boundary, wrong granularity, floating-point numbers, technical limits missing from the specification.
  • An unspecified limit is already a defect in the test basis: ask before coding your cases.

FAQ

What is a boundary value in software testing?

It is the value at the edge of an ordered partition: its minimum or maximum. From there, the expected behaviour of the system changes. You test that value and its immediate neighbours.

Should I test 2 or 3 values per boundary?

Both variants exist. The 3-value version catches more comparison errors for a slightly higher cost; it is preferable for high-stakes rules (money, access rights, security). The 2-value version suits low risk and limited time.

What is the difference between equivalence partitioning and boundary value analysis?

Equivalence partitioning splits the domain and tests one representative value per group. Boundary value analysis completes that split by testing the edges of each group, where defects are most frequent. The two techniques are combined.

Sources

What's next?

Want to know where you stand on test design techniques? Take the free diagnostic: 10 questions, about 5 minutes. And if you would rather follow new articles by email, QAcademy sends a weekly newsletter (at most one email a week, one-click unsubscribe).

Take the next step

You have just read. Now see where you stand: 10 questions, your score chapter by chapter, free and without signing up.

Take the free test (5 min)

Already decided to practise?

One-off payment, no subscription, refunded within 14 days if it is not for you.

Get the new articles by email

At most one email a week: the new QAcademy articles on software testing and quality. Free, unsubscribe in one click.

5 minutes · free · no sign-up

Before you go: where do you stand?

10 questions in the exam format, about 5 minutes: your score by chapter and your gap to the pass mark.

5 minutes · free · no sign-up