~/qa-guides/boundary-value-analysis
>_ Boundary Value Analysis: Examples and Test Cases
Derive boundary test cases with five worked examples covering numbers, text length, tiered outcomes, and expiry times, plus 2-value and 3-value BVA.
Short answer
Boundary value analysis (BVA) is a black-box test design technique that selects values at and immediately around the edges of ordered equivalence partitions. It helps turn a rule such as "accept quantities from 1 to 100 inclusive" into inputs with independently defined expected results.
Start by specifying the input domain, the partitions, whether each limit is included, and the smallest meaningful step. Then choose boundary inputs, submit them through the interface under test, and check both the response and any saved result.
This guide works through integer quantities, decimal setpoints, text lengths, tiered outcomes, and expiry times. It also explains why 2-value and 3-value BVA do not imply one fixed number of tests for every requirement.
Boundary value analysis and equivalence partitioning
Equivalence partitioning groups inputs that should receive similar treatment. BVA selects tests around the edges of those groups, so the partition model comes first.
Use Equivalence Partitioning: Examples and Test Cases to define valid and invalid classes, select representatives, and distinguish class coverage from combinations across fields.
For an integer quantity accepted from 1 through 100, a useful model is:
- Below the allowed range: Any integer of 0 or less is rejected.
- Within the allowed range: Integers from 1 through 100 are accepted.
- Above the allowed range: Any integer of 101 or more is rejected.
An ordinary value such as 50 represents the accepted partition. Values 0, 1, 100, and 101 specifically exercise the transitions between acceptance and rejection.
The broader distinction between deriving tests from requirements and deriving them from code is covered in Black-Box vs White-Box Testing.
Use BVA when a changed requirement introduces a quantity limit, length restriction, threshold, or another ordered range. Categories such as payment method names need a different selection rule unless the requirement gives them a meaningful ordering.
How to derive boundary test inputs
1. Write the rule before selecting numbers
Replace "test the minimum and maximum" with a complete acceptance rule. Record the type, units, limits, and behavior on either side.
For example, "temperature must be between 10 and 25" leaves questions unanswered. Does exactly 25 pass? Are hundredths allowed? Does the system reject extra precision or round it first?
Resolve those questions with the requirement owner before assigning expected results. The current implementation is something to test, not the authority that decides which result is correct.
2. Identify each change in expected behavior
List the ordered groups and the outcome for each. A range may have two acceptance transitions; a tiered calculation may have several transitions between different valid outcomes.
Do not merge two groups just because both return success. If a rule changes the calculated amount or permitted action at a threshold, that transition also needs test inputs.
3. Specify what one step means
For integer quantities, the neighboring value is one unit away. For a decimal field accepting hundredths, it is 0.01 away. For a text-length rule, it is one unit of the agreed length measure.
Do not automatically subtract or add 1. A decimal test at 9.00 does not exercise the immediate neighbor of 10.00 when 9.99 is a permitted input. A continuous mathematical range has no nearest real-number neighbor; choose test precision explicitly.
4. Assign an observable result to every input
Write down more than "valid" or "invalid." For an accepted value, specify the stored value or calculated result. For a rejected value, specify the validation outcome and the state that must remain unchanged.
Keep other fields valid while exercising one boundary. If a request also has an expired session or missing required field, its rejection does not establish that the boundary rule worked.
2-value vs 3-value boundary value analysis
The terminology here follows section 4.2.2 of the ISTQB Foundation Level syllabus v4.0.1:
- 2-value BVA: Exercise each identified boundary value and its nearest neighbor in the adjacent partition.
- 3-value BVA: Exercise each identified boundary value and its immediate neighbor on each side.
Deduplicate overlapping inputs after deriving them from all identified boundaries. Name the partitions and coverage scope alongside the test set; counting inputs alone does not establish coverage.
Worked example 1: Integer quantity from 1 to 100
For this example, the input domain is integers. A booking request accepts quantity 1 through 100 inclusive. An accepted request creates one booking with that exact quantity. An out-of-range request returns a quantity validation error and creates no booking. Assume availability and all other fields are valid.
The three partitions are integers at or below 0, integers from 1 through 100, and integers at or above 101. Their boundary values at the acceptance transitions are 0, 1, 100, and 101.
The 2-value set has four distinct inputs:
0: Reject; no booking is created.1: Accept; the new booking has quantity 1.100: Accept; the new booking has quantity 100.101: Reject; no booking is created.
The 3-value set has eight distinct inputs:
-1,0: Reject each request; neither creates a booking.1,2: Accept each request with its exact submitted quantity.99,100: Accept each request with its exact submitted quantity.101,102: Reject each request; neither creates a booking.
For example, boundary 0 contributes -1, 0, and 1; boundary 1 contributes 0, 1, and 2. Taking their union gives -1, 0, 1, and 2 at the lower transition. Apply the same process to boundaries 100 and 101 at the upper transition.
The familiar six inputs 0, 1, 2, 99, 100, and 101 surround the accepted interval's endpoints. They do not include the outside neighbors of boundaries 0 and 101, so they are not the complete 3-value set for all four identified boundaries in this model.
Test case: Accept the maximum booking quantity
- Preconditions: A fresh booking request has valid customer details and sufficient availability; the allowed integer quantity is 1 through 100 inclusive.
- Input: Quantity
100. - Steps: Submit the request once, then retrieve the booking created by that request.
- Expected result: The request succeeds and creates exactly one booking with quantity 100.
Test case: Reject one unit above the maximum
- Preconditions: Use the same valid setup with no booking already created by this request.
- Input: Quantity
101. - Steps: Submit the request once, then check the response and whether that request created a booking.
- Expected result: A quantity validation error is returned and no booking is created.
Run each input as an independent case. Add an ordinary accepted value such as 50 if the suite also needs a representative interior check; label it separately from the boundary set.
Which defects do the selected inputs detect?
Use the quantity rule from the first example to connect each input to a possible implementation error. The requirement remains 1 through 100 inclusive; the incorrect behaviors below are hypothetical defects, not alternative requirements.
- The lower limit moves from 1 to 0: Input
0should be rejected. If a booking is created, this test exposes the extra accepted value. - The upper limit becomes exclusive: Input
100should succeed. Rejecting it exposes a condition equivalent to "quantity is less than 100" where the requirement allows exactly 100. - The upper limit moves from 100 to 101: Input
101should be rejected. Accepting it exposes the incorrectly extended range.
All three errors are detectable with the four-input 2-value set already derived. An interior input such as 50 would pass under each incorrect rule, so testing 50 alone would miss them.
What can the extra 3-value inputs reveal?
Suppose the validator mistakenly accepts only quantity 1 or quantity 100 instead of the entire interval. The four 2-value cases still behave as expected: 0 and 101 are rejected, while 1 and 100 are accepted.
The additional inputs 2 and 99 must also succeed. Their rejection reveals the defect, so the 3-value set detects a failure that the four-input set misses. An ordinary interior case such as 50 would detect this particular error too, but it was selected for a different coverage purpose.
Do not turn that example into a guarantee. An implementation could still mishandle quantity 50 while treating every selected boundary input correctly. Passing the boundary set establishes the observed results for those inputs, not correctness throughout the interval.
For a limited execution budget, first identify the changed or consequential transitions and record which coverage items will actually run. Use the extra neighbors when a more detailed check of behavior around those edges is warranted. Keep interior representatives and interaction tests when they address additional risks; do not report partial execution as complete boundary coverage.
Worked example 2: Decimal range with an exclusive maximum
Assume a settings service accepts a temperature setpoint when 10.00 <= temperature < 25.00, in degrees Celsius. The numeric test domain uses increments of 0.01. Inputs with extra decimal places are rejected rather than rounded. Every case starts with a saved setpoint of 18.00.
The lower limit is inclusive, so 10.00 is accepted. The upper limit is exclusive, so 25.00 is rejected; the largest accepted input is 24.99.
At the two acceptance transitions, the 2-value inputs and expected results are:
9.99: Reject with a range validation error; the saved setpoint remains 18.00.10.00: Accept and save 10.00.24.99: Accept and save 24.99.25.00: Reject with a range validation error; the saved setpoint remains 18.00.
For 3-value coverage of these four boundary values, also include 9.98, 10.01, 24.98, and 25.01. Reject 9.98 and 25.01 without changing the saved value; accept and save 10.01 and 24.98.
Test case: Reject the exclusive upper limit
- Preconditions: The saved setpoint is 18.00, the caller can edit it, and the rule is
10.00 <= temperature < 25.00with 0.01 precision. - Input: Temperature
25.00degrees Celsius. - Steps: Submit the settings update, then read the saved setting again.
- Expected result: The update is rejected with a range validation error; the saved setpoint remains 18.00.
Test a value such as 24.999 separately for the precision rule. It is not the immediate neighbor of 25.00 in the declared 0.01 domain. Changing the contract to round first would require a different expectation and tests for that transformation.
For request construction and response assertions, the API Test Cases Checklist provides a broader structure. Use the service's documented response status and error format; a particular HTTP status is not part of BVA itself.
Worked example 3: Text length from 3 to 12
Assume a display name must contain 3 through 12 ASCII letters, with no spaces or trimming. A successful update saves the exact submitted name. A rejected update leaves the existing name unchanged. These fixtures deliberately avoid ambiguity about how length is counted.
Start with the inputs on either side of the two acceptance transitions:
ab, length 2: Reject as too short; keep the existing name.abc, length 3: Accept and saveabc.abcdefghijkl, length 12: Accept and saveabcdefghijkl.abcdefghijklm, length 13: Reject as too long; keep the existing name.
For additional neighboring lengths, use a at length 1, abcd at length 4, abcdefghijk at length 11, and abcdefghijklmn at length 14. Lengths 1 and 14 are rejected; lengths 4 and 11 are accepted.
An empty name is another useful invalid case. Missing fields, unsupported characters, and whitespace-only values should have their own expectations; they do not replace the length-transition tests above.
Test case: Reject an overlong name at the service boundary
- Preconditions: The current name is
Jane; the update service enforces the 3-to-12-letter rule, and the caller is authorized. - Input: Display name
abcdefghijklm, exactly 13 ASCII letters. - Steps: Send the value directly to the update service, then retrieve the profile.
- Expected result: A length validation error is returned and the saved name remains
Jane.
Check the form's input behavior separately
A browser input with maxlength may prevent an overlong value from being entered. In that case, a UI test may never send the 13-letter fixture to the service. Check the form's agreed input behavior, and use a direct service request to test server rejection.
MDN's maxlength documentation explains that the HTML limit counts UTF-16 code units and that browsers generally prevent input beyond the limit. That measure does not always match the number of characters a person perceives.
For a field supporting other scripts or emoji, define the length measure before reusing these expectations. If the product trims or normalizes text, specify whether the limit applies before or after that transformation. The Form Testing Checklist covers the surrounding input and validation behavior.
Worked example 4: Several valid ranges with different outcomes
Assume a parcel routing service accepts integer weights in grams. Every accepted request returns one route identifier according to these example rules:
- 1 through 500 grams: Return route
small. - 501 through 1000 grams: Return route
medium. - 1001 through 2000 grams: Return route
large. - 0 or less, or 2001 or more: Reject with a weight validation error and return no route.
The step is 1 gram. All other routing information is valid, and the rules above completely determine the result for this example. There are three accepted partitions with different outputs, plus a rejected partition on either side.
The 2-value set covers four transitions:
0: Reject;1: Accept with routesmall.500: Accept with routesmall;501: Accept with routemedium.1000: Accept with routemedium;1001: Accept with routelarge.2000: Accept with routelarge;2001: Reject.
A check that only asserts success for weights 500 and 501 misses an important part of the rule. Both requests should succeed, but their route identifiers must differ. If the implementation incorrectly assigns weight 501 to small, the acceptance check passes while the result is wrong.
Test case: Select the next route at 501 grams
- Preconditions: The caller submits a valid routing request, and the agreed weight bands are 1-500, 501-1000, and 1001-2000 grams.
- Input: Weight
501grams. - Steps: Request a route and inspect the returned route identifier.
- Expected result: The request succeeds with route
medium; it does not returnsmallorlarge.
Pair this with the independent 500-gram case, which must return small. Together they check the transition's two outcomes.
For 3-value coverage of all eight identified boundary values, add -1, 2, 499, 502, 999, 1002, 1999, and 2002. Reject -1 and 2002; return small for 2 and 499, medium for 502 and 999, and large for 1002 and 1999. The resulting union has 16 distinct inputs.
Worked example 5: An expiry time with millisecond precision
Assume a temporary report download is available only while now < expiresAt. The service evaluates this rule when it validates the download request. For this example, both values use UTC and the comparison operates in whole milliseconds. The download can be repeated before expiry, and all other eligibility checks pass.
Set expiresAt to 2026-11-11T12:00:00.000Z. The specified cutoff is exclusive: exactly at that instant, the report is already unavailable. A product that defines an inclusive cutoff or a grace period needs different expectations.
Start with these checkpoints, each in a fresh test setup:
- Before expiry: At
2026-11-11T11:59:59.999Z, the request succeeds and returns the intended report. - Exactly at expiry: At
2026-11-11T12:00:00.000Z, the request is rejected as expired and does not return the report content. - After expiry: At
2026-11-11T12:00:00.001Z, the request is rejected as expired and does not return the report content.
Derive the time neighbors from the same partition model
The last available millisecond is 11:59:59.999Z; the first expired millisecond is 12:00:00.000Z on the stated date. Those are the two boundary values at this transition, and together they form its 2-value set.
To cover both boundaries and their neighbors with 3-value BVA, also test 11:59:59.998Z and 12:00:00.001Z on that date. The first succeeds; the second is rejected as expired. This gives four distinct timestamps. The three business checkpoints above are useful, but they omit the neighbor immediately before the last available millisecond.
Test case: Reject a download exactly at expiry
- Preconditions: The report exists, the caller otherwise qualifies to download it, and expiry is
2026-11-11T12:00:00.000Zunder the exclusive-cutoff rule. - Input: The service's evaluation clock is fixed at
2026-11-11T12:00:00.000Z. - Steps: Submit the download request and inspect the response while the evaluation clock remains fixed.
- Expected result: The service reports that the download has expired and returns no report content.
Control the evaluation clock in the test environment instead of trying to send a live request at an exact wall-clock instant. Network delay can move request validation past the cutoff. Changing only the browser's clock does not control a service that evaluates its own time.
Record where the contract evaluates expiry: request validation, job start, or another defined event. A request started before expiry and processed after it cannot have a reliable expected result until that event is specified. A system comparing whole seconds also needs a different neighboring step from this millisecond example.
If the interface accepts timestamps with explicit offsets, an additional representation check can compare expiry 2026-11-11T14:00:00.000+02:00 with the UTC expiry above. They describe the same instant, so the cutoff result must remain the same under this example's rule. Keep that representation check separate from the boundary coverage count.
For calendar dates, ambiguous local appointments, and daily report intervals across clock changes, use the worked examples in the date and time testing checklist.
Reusable boundary test case template
Record these fields for each selected input:
- Rule: The requirement, allowed range, inclusivity, units, and precision or length measure.
- Coverage target: The partition boundary and why this input was selected.
- Preconditions: Valid values for other fields, permissions, existing state, and any required capacity.
- Input and steps: The exact value, the interface used, and the action that triggers evaluation.
- Expected result: Acceptance or rejection, the response, and the stored value or side effect that must occur or remain unchanged.
- Evidence: The observed response and relevant saved state, recorded after execution.
A collection of numbers without expected outcomes is test data, not a complete set of executable test cases.
Boundary testing checklist
- Confirm that the requirement states whether each limit is inclusive or exclusive.
- Record the smallest input step and its unit before deriving neighboring values.
- List every ordered partition where the expected result changes.
- Map selected inputs to the identified boundaries and the chosen 2-value or 3-value scope.
- Verify the required result on both sides of each transition, including transitions between different accepted outcomes.
- Check that accepted inputs produce the required stored or calculated value.
- Check that rejected inputs leave the relevant saved state unchanged.
- Keep unrelated fields valid so another error cannot mask the boundary result.
- Exercise server validation directly when the UI prevents an invalid input from reaching it.
- For time rules, control the evaluation clock and verify the exact cutoff at the contract's stated precision.
- Add separate expectations for missing values, invalid types, and transformations such as rounding or trimming.
Common mistakes
- Testing only values well inside the accepted range. Quantities 20 and 80 do not distinguish an inclusive maximum of 100 from an incorrectly implemented maximum of 99.
- Using the same step for every type. Adding 1 to a decimal threshold can skip the immediate neighboring input that the contract permits.
- Treating every written limit as accepted. An exclusive maximum changes which side of the transition the exact threshold belongs to.
- Calling a test set complete without naming its partitions. Four or six inputs may cover a chosen scope, but the count alone says nothing about omitted transitions.
- Accepting the error message as the entire result. A rejected update that still changes saved data violates the example contracts even if validation text appears.
- Assuming UI prevention proves service validation. A field that caps text length can hide a service that accepts overlong direct requests.
FAQ
No. A boundary set usually includes accepted and rejected inputs. For a quantity allowed from 1 through 100, both 1 and 100 must succeed; rejecting either is a defect even if 0 and 101 are correctly rejected.
No. The count depends on the identified boundary values, their neighbors, and overlaps between the resulting inputs. For the integer partitions in this guide, four boundary values produce eight distinct inputs under the stated 3-value coverage model.
Derive inputs around that acceptance transition using the declared step. Do not invent a business maximum. If the interface or storage has another documented limit, record it as a separate rule and test its boundary too.
First exercise each field's boundaries while holding the other field at an ordinary valid value. Then add cases for interactions required by the contract, such as an end value that must exceed a start value. Covering each field separately does not establish that their relationship is correct.
Yes. A parameterized test can run the selected inputs with their expected responses and saved-state assertions. Keep the rule and expected outcomes explicit so a change in the implementation does not silently redefine what the test accepts.