Boundary Value Testing
Introduction
Many software defects occur at the boundaries of input ranges rather than in the middle of valid values. A field may work correctly for ordinary values such as 25, 50, or 75, but fail when the value is exactly the minimum, exactly the maximum, just below the minimum, or just above the maximum. These failures happen because code often uses comparison operators, range checks, limits, counters, array sizes, string lengths, date calculations, pagination offsets, and numeric conversions. A small mistake in one of these areas can produce a serious defect.
Boundary Value Testing, often called BVT, is a black-box test design technique used to verify that an application correctly handles values at the edges of valid and invalid input ranges. Instead of testing many random values, testers focus on the values most likely to reveal range-related defects. In API testing, Boundary Value Testing is used for numbers, string lengths, dates, pagination limits, file sizes, request payload sizes, array counts, query parameters, path parameters, and business-rule limits.
Boundary Value Testing is closely related to Equivalence Partitioning. Equivalence Partitioning divides input data into valid and invalid groups. Boundary Value Testing then focuses on the edges of those groups. For example, if age is valid from 18 to 60, Equivalence Partitioning may test one valid value such as 30 and one invalid value such as 10. Boundary Value Testing goes further by testing 17, 18, 19, 59, 60, and 61. These edge values are more likely to reveal off-by-one errors and incorrect comparison logic.
For API testers, BVT is especially practical because APIs expose business rules directly. A user interface may prevent invalid input through form controls, but clients can call APIs directly with any value they want. The backend must enforce all boundaries independently. Boundary Value Testing confirms that the API accepts valid edge values, rejects invalid edge values, and keeps system state correct.
What Is Boundary Value Testing?
Boundary Value Testing is a testing technique that verifies application behavior using values at the minimum, maximum, and just inside and outside the valid input boundaries. It focuses on the edge values of a range because defects often occur where valid data changes into invalid data.
A simple definition is this: Boundary Value Testing checks how an API behaves at the edge values of valid and invalid input ranges. If an input field accepts values from 1 to 100, the most important values are not only 50 or 75. The most important values are 0, 1, 2, 99, 100, and 101. These values test just below minimum, minimum, just above minimum, just below maximum, maximum, and just above maximum.
Boundary Value Testing is black-box testing because testers do not need to know the internal code. They need to know the input rule. Once the rule is known, test values can be derived systematically. If the API specification says `pageSize` must be between 1 and 100, the tester can design boundary tests without reading the source code.
BVT is not limited to numeric fields. It applies to any constrained input. A string may have a maximum length of 50 characters. A file upload may allow up to 10 MB. A request body may allow up to 1 MB. A date may be allowed only between today and 90 days from today. An array may allow 1 to 20 items. Each of these rules has boundaries that should be tested.
Why Boundary Value Testing Is Important
Boundary testing is important because it detects edge-case defects that are easy to miss with ordinary test data. A developer may write `age > 18` instead of `age >= 18`, causing age 18 to be rejected incorrectly. Another developer may write `quantity <= 100` in one service but `quantity < 100` in another service, causing inconsistent behavior at exactly 100. These are classic boundary defects.
BVT validates input limits and business rules. Many APIs implement important restrictions: minimum transfer amount, maximum order quantity, maximum file size, maximum password length, earliest allowed date, latest allowed date, maximum page size, maximum array count, and maximum request body size. If these limits are wrong, users may be blocked from valid actions or allowed to perform invalid actions.
Boundary testing also helps prevent overflow, underflow, and resource issues. Extremely large numbers, oversized payloads, long strings, and large arrays can cause performance problems, memory issues, database errors, or application crashes. Boundary tests help verify that the API handles limits predictably before clients discover weaknesses in production.
From a regression perspective, BVT is efficient. It gives high value with a small number of carefully selected test cases. Instead of testing every value from 1 to 100, the tester can test the boundary set and a representative middle value. This reduces effort while increasing the chance of finding range-related defects.
Why Boundary Bugs Occur
Boundary bugs commonly occur because of incorrect comparison operators. A requirement may say that values from 1 to 100 are valid, but the code may use `value > 1` instead of `value >= 1`, or `value < 100` instead of `value <= 100`. These mistakes reject valid boundary values. The opposite mistake may accept invalid values just outside the range.
Off-by-one errors are another common cause. Pagination, arrays, indexes, string lengths, and counters frequently produce off-by-one problems. A page size limit of 100 may accidentally allow 101. A string field with maximum length 50 may reject exactly 50 characters. A date range may include one extra day or exclude the last valid day.
Missing validation also creates boundary defects. The user interface may enforce limits, but the API may not. When a client sends a direct API request with values outside the UI controls, the backend may accept invalid data. API testing must verify server-side validation independently of the frontend.
Boundary bugs can also occur because business rules are misunderstood. A minimum transfer amount may be inclusive, while a discount threshold may be exclusive. A maximum booking window may count calendar days, business days, or full 24-hour periods. Testers should clarify whether boundaries are inclusive or exclusive before writing expected results.
Boundary Testing Workflow
A practical BVT workflow starts by identifying the input range. The tester reads the API specification, acceptance criteria, validation rules, database constraints, business rules, or product requirements. Then the tester finds the minimum and maximum values. After that, the tester creates boundary values around those limits and verifies the API response.
Identify Input Range
|
Find Minimum and Maximum
|
Test Boundary Values
|
Verify API Response
|
Validate Business Rules
The workflow must include both response validation and state validation. If a value is invalid, the API should return the correct error and avoid changing backend data. If a value is valid, the API should accept it and process the business operation correctly. For write operations, this may require checking the database, a follow-up API call, an event, or an audit record.
Boundary testing should be documented clearly because expected behavior depends on inclusivity. If the requirement says age 18 to 60 is valid, the test should specify that 18 and 60 are accepted. If a limit is exclusive, the test should specify that the boundary itself is rejected. Ambiguous requirements should be clarified before automation.
Basic Boundary Rule
For a valid range with a minimum and maximum, the classic boundary test values are minimum minus one, minimum, minimum plus one, maximum minus one, maximum, and maximum plus one. If the range is 1 to 100, the boundary values are 0, 1, 2, 99, 100, and 101.
Valid range: 1 to 100
Test values:
0 - just below minimum
1 - minimum
2 - just above minimum
99 - just below maximum
100 - maximum
101 - just above maximum
This six-value approach is effective because it tests both valid and invalid edges. The values 1 and 100 confirm that the API accepts the exact limits. The values 0 and 101 confirm that the API rejects values just outside the limits. The values 2 and 99 confirm behavior just inside the valid range. Together, these values reveal many comparison and off-by-one defects.
Some teams also include a middle value such as 50. This is useful when combining BVT with Equivalence Partitioning. The boundary values check the edges, while the middle value confirms ordinary valid behavior.
Age Validation Example
Consider an API rule that employee age must be between 18 and 60. The boundary values are 17, 18, 19, 59, 60, and 61. Values 18, 19, 59, and 60 should be accepted. Values 17 and 61 should be rejected.
| Input | Expected Result |
|---|---|
| 17 | Rejected |
| 18 | Accepted |
| 19 | Accepted |
| 59 | Accepted |
| 60 | Accepted |
| 61 | Rejected |
This simple example can reveal multiple defects. If 18 is rejected, the minimum comparison is wrong. If 17 is accepted, lower-bound validation is weak. If 60 is rejected, the maximum comparison is wrong. If 61 is accepted, upper-bound validation is weak.
Salary and String Length Examples
For a salary rule from 1000 to 100000, the boundary values are 999, 1000, 1001, 99999, 100000, and 100001. The values 1000 and 100000 are especially important because they confirm that the exact boundaries are accepted when the requirement is inclusive.
String length boundaries are equally important. If a `name` field accepts 1 to 50 characters, the boundary lengths are 0, 1, 2, 49, 50, and 51. A test should generate actual strings of those lengths and verify the response. The API should reject length 0 if name is mandatory, accept length 1, accept length 50, and reject length 51.
| Length | Expected Result |
|---|---|
| 0 | Rejected |
| 1 | Accepted |
| 2 | Accepted |
| 49 | Accepted |
| 50 | Accepted |
| 51 | Rejected |
String boundary testing should include character counting rules. Some systems count Unicode characters differently from bytes. A name with accented characters or emoji may have a different byte length than visible character count. If the API stores data in byte-limited database columns, testers should understand whether the limit is based on characters, bytes, or both.
Pagination and File Upload Examples
Pagination limits are common API boundary points. If `pageSize` is allowed from 1 to 100, test 0, 1, 2, 99, 100, and 101. The API should reject 0 and 101, accept 1 and 100, and return the expected number of records for valid values.
Pagination boundary tests should also verify metadata. If the API returns `page`, `size`, `totalElements`, or `totalPages`, those values should remain consistent. A valid `pageSize=100` should not return 101 records. A rejected `pageSize=101` should not silently reduce the value to 100 unless that behavior is explicitly documented.
File upload boundaries test maximum file size. If the maximum file size is 10 MB, test slightly below 10 MB, exactly 10 MB, and slightly above 10 MB. The exact expected results depend on whether the API defines the limit in decimal megabytes, binary mebibytes, or bytes. The test data should match the specification precisely.
Request payload boundaries are similar. If the maximum request body is 1 MB, test 0.99 MB, 1 MB, and 1.01 MB. Oversized payloads should be rejected gracefully with a documented error. They should not crash the service, produce partial records, or consume excessive resources.
Boundary Value Formula
The standard formula for a range from minimum to maximum is simple: test minimum minus one, minimum, minimum plus one, maximum minus one, maximum, and maximum plus one. This is the classic six-value boundary test for a single input field.
For range Min to Max:
Min - 1
Min
Min + 1
Max - 1
Max
Max + 1
For example, if the range is 18 to 60, the values are 17, 18, 19, 59, 60, and 61. If the range is 1 to 100, the values are 0, 1, 2, 99, 100, and 101. If the range is 1000 to 100000, the values are 999, 1000, 1001, 99999, 100000, and 100001.
The formula is easy to automate. Test data can be generated from field metadata or validation rules. This makes BVT a good candidate for data-driven API testing, especially when multiple fields have clear minimum and maximum constraints.
Types of Boundary Value Testing
Normal Boundary Testing focuses on valid boundaries. It may test values such as minimum, minimum plus one, maximum minus one, and maximum. This approach confirms that the valid edge values are accepted correctly.
Robust Boundary Testing includes invalid values outside the range. It tests minimum minus one and maximum plus one in addition to valid boundary values. This is more useful for API testing because APIs must reject invalid direct requests.
Worst-Case Boundary Testing is used when multiple inputs have boundaries and combinations of boundary values are tested. For example, a transfer API may include amount, description length, recipient count, and date range. Testing every combination can produce many cases, so testers should prioritize combinations based on risk and business impact.
Robust worst-case testing can become large quickly. If five fields each have six boundary values, exhaustive combinations may be impractical. In that case, testers can combine pairwise testing, risk-based selection, and focused combinations for the most critical rules.
Boundary Testing in API Testing
API testers should apply Boundary Value Testing to numeric limits, string length, date ranges, pagination limits, file size limits, request body size, array size, query parameter limits, path parameter validation, and business rule limits. Any input with a lower or upper constraint is a candidate for BVT.
Numeric limits include age, salary, quantity, transfer amount, discount percentage, tax rate, price, score, page number, and page size. String limits include name, description, comments, titles, tags, and codes. Date limits include birth dates, booking dates, expiry dates, start and end ranges, and reporting periods.
Array boundaries are common in APIs that accept lists. For example, an order may allow 1 to 99 line items. A bulk update endpoint may allow up to 100 records. A notification API may allow up to 50 recipients. Testers should verify zero items, one item, maximum allowed items, and one more than maximum.
Business rule boundaries are often the most important. A bank may allow transfers from 1 to 10000. An e-commerce system may allow order quantity from 1 to 99. A healthcare system may allow patient age from 0 to 120. These limits are not just technical validations; they represent business policy.
Example API Test Cases
For an age field with a valid range of 18 to 60, a minimum value test sends age 18 and expects success. A below-minimum test sends age 17 and expects a validation error. A maximum value test sends age 60 and expects success. An above-maximum test sends age 61 and expects a validation error.
For a string field with maximum length 50, a test with exactly 50 characters should succeed. A test with 51 characters should fail. If the field is mandatory and minimum length is 1, an empty string should fail, while a one-character string should succeed.
For pagination, `pageSize=1` should return at most one item, `pageSize=100` should return at most 100 items, and `pageSize=101` should fail if 100 is the documented maximum. If the API defaults invalid values silently, testers should verify whether that behavior is documented and acceptable.
For file upload, a 10 MB file should succeed if the maximum is inclusive, while a file slightly larger than 10 MB should fail. The rejected response should be controlled and should not leave partial uploaded files behind.
REST Assured Example
REST Assured can automate boundary tests in Java. A below-minimum age test may send age 17 and expect `400 Bad Request`.
given()
.contentType("application/json")
.body("""
{
"age": 17
}
""")
.when()
.post("/employees")
.then()
.statusCode(400);
A valid minimum boundary test sends age 18 and expects success according to the API contract.
given()
.contentType("application/json")
.body("""
{
"age": 18
}
""")
.when()
.post("/employees")
.then()
.statusCode(200);
In real projects, these tests should also validate the response body, validation message, field name, schema, and database state where applicable. For invalid values, confirm that no record is created or modified. For valid boundary values, confirm that the API processes the data correctly.
Postman Example
In Postman, testers can create a collection with variables for boundary values. For an age field, test values may include minimum, minimum minus one, minimum plus one, maximum, maximum minus one, and maximum plus one. The same request can be executed with different data rows using the collection runner.
Postman tests should verify status code, validation message, response body, response headers, and response time. For create or update endpoints, testers may also verify database changes through follow-up API calls. For example, after sending age 18, a `GET` request can confirm that the employee was created with age 18. After sending age 17, a search request can confirm no invalid record exists.
Postman is useful for early exploration because testers can quickly try boundary values while the API is under development. Once the expected behavior is stable, the same scenarios can be automated through Newman or moved into code-based API automation.
Karate Example
Karate can express boundary tests in a readable scenario format. A below-minimum age test may look like this:
Given request
"""
{
"age": 17
}
"""
When method POST
Then status 400
Karate also supports scenario outlines and examples tables, which are useful for boundary value matrices. A single scenario can run with values such as 17, 18, 19, 59, 60, and 61. The expected status can be driven by the examples table, making the boundary test compact and readable.
Real-World Examples
In banking, a transfer API may allow transfer amounts from 1 to 10000. Boundary tests should include 0, 1, 2, 9999, 10000, and 10001. The API should reject 0 and 10001, accept 1 and 10000, and update balances correctly for valid values. For invalid values, balances should remain unchanged.
In healthcare, patient age may be allowed from 0 to 120. Boundary tests include -1, 0, 1, 119, 120, and 121. The API should reject impossible ages and accept valid boundaries. If newborn age is represented differently, the requirement should clarify whether 0 is valid.
In e-commerce, order quantity may be allowed from 1 to 99. Boundary tests include 0, 1, 2, 98, 99, and 100. The API should reject zero quantity, accept one item, accept the maximum, and reject more than maximum. Inventory should update only for valid orders.
In employee management, salary may be allowed from 1000 to 100000. Boundary tests include 999, 1000, 1001, 99999, 100000, and 100001. The API should enforce these boundaries consistently during create and update operations.
Advantages of Boundary Value Testing
Boundary Value Testing detects edge-case defects and finds off-by-one errors. It improves input validation and helps testers focus on the values most likely to fail. It is simple, systematic, and easy to explain to developers, business analysts, and interviewers.
BVT reduces testing effort while increasing effectiveness. Instead of testing many values randomly, testers use a small set of meaningful values around the boundaries. This makes test design efficient and repeatable. It also supports automation because boundary values can be derived from validation rules.
Boundary Value Testing works well with Equivalence Partitioning. Equivalence Partitioning identifies the valid and invalid groups. BVT tests the edges of those groups. Together, they provide strong coverage with fewer test cases than exhaustive testing.
Limitations of Boundary Value Testing
Boundary Value Testing focuses on boundary values, so it may miss defects in middle-range values. If a business rule has special logic for a middle value, BVT alone may not find it. For example, a discount rule may change at 50 even if the valid range is 1 to 100. That internal threshold also needs testing.
BVT is less effective for complex business logic when boundaries are not clearly numeric or length-based. Workflows, state transitions, permissions, concurrency, and integrations require additional test techniques. Boundary testing does not replace exploratory testing, negative testing, security testing, or business scenario testing.
Another limitation is that boundary combinations can grow quickly when multiple inputs have limits. Testers must prioritize based on risk. Exhaustive worst-case boundary testing may be impractical for large APIs, so a balanced test design is needed.
Boundary Value Testing vs Equivalence Partitioning
Boundary Value Testing and Equivalence Partitioning are often used together, but they focus on different things. Equivalence Partitioning tests representative values from input groups. Boundary Value Testing tests values at the edges of those groups.
| Boundary Value Testing | Equivalence Partitioning |
|---|---|
| Tests edge values | Tests representative values from each partition |
| Focuses on limits | Focuses on input groups |
| Detects boundary defects | Reduces the number of test cases |
| Often used with partitioning | Often used with boundary testing |
For an age range of 18 to 60, Equivalence Partitioning may choose one valid value such as 30 and one invalid value such as 10. Boundary Value Testing adds 17, 18, 19, 59, 60, and 61. The combination gives better confidence than either technique alone.
Best Practices
Identify every input range before designing boundary tests. Review API documentation, request schemas, validation annotations, business rules, database constraints, and acceptance criteria. Do not test only obvious numeric fields. Look for string lengths, array counts, date ranges, file sizes, payload sizes, page sizes, and business limits.
Test minimum and maximum values, and include values just inside and just outside boundaries. Test both valid and invalid limits. Verify the response status, error message, response body, headers, and backend state. Combine Boundary Value Testing with Equivalence Partitioning for stronger coverage.
Automate boundary test cases where possible. Boundary values are deterministic and make good regression tests. Use data-driven testing to avoid duplicating code. Keep expected results clear so failed tests are easy to diagnose.
Clarify inclusive and exclusive boundaries. If the requirement says "less than 100", then 100 is invalid. If it says "up to 100", then 100 may be valid. Ambiguous wording leads to wrong tests and wrong implementations.
Common Mistakes
A common mistake is testing only the minimum and maximum values. Testers should also test the values immediately inside and outside the boundaries. For a range of 1 to 100, testing only 1 and 100 misses whether 0 and 101 are rejected.
Another mistake is ignoring business rules. Technical field limits are important, but business-specific boundaries are just as important. A transfer amount, order quantity, booking window, age range, discount threshold, or credit limit may be more critical than a generic string length.
Forgetting string boundaries is also common. APIs often fail when string fields are empty, exactly at maximum length, or one character too long. Testers should generate actual strings of the required lengths instead of guessing.
Ignoring API payload limits is risky. Large payloads, large arrays, and large files can create performance and stability issues. Boundary testing should include request size and collection size limits, not only individual fields.
Common HTTP Status Codes
Boundary test expectations should follow the API specification. Valid boundary values usually return success responses such as `200 OK` or `201 Created`. Invalid boundary values commonly return `400 Bad Request` or `422 Unprocessable Entity` depending on the API standard.
| Scenario | Status Code |
|---|---|
| Valid boundary value | 200 OK or 201 Created |
| Invalid boundary value | 400 Bad Request |
| Validation error where used | 422 Unprocessable Entity |
Some APIs use `400 Bad Request` for all validation failures. Others use `422 Unprocessable Entity` when the request syntax is valid but business validation fails. Testers should follow the documented API behavior and raise inconsistencies when endpoints behave differently without a clear reason.
Boundary Testing Checklist
For each endpoint, ask whether any request field has a minimum, maximum, allowed length, allowed count, date range, file size, payload size, page size, numeric range, or business threshold. If yes, identify the exact lower and upper boundaries. Then create tests for just below minimum, minimum, just above minimum, just below maximum, maximum, and just above maximum.
For valid boundary values, verify success response, response body, schema, database updates, and business behavior. For invalid boundary values, verify validation response, error message, unchanged state, and no sensitive leakage. For multi-field requests, test high-risk boundary combinations and not just one field at a time.
Interview Questions
A common interview question is: what is Boundary Value Testing? A strong answer is that Boundary Value Testing is a black-box testing technique that verifies application behavior using values at the edges of valid and invalid input ranges.
Another question is: why is Boundary Value Testing important? The answer is that many software defects occur at minimum and maximum boundaries due to incorrect validation, comparison logic, off-by-one errors, missing checks, or misunderstood business rules.
Interviewers may ask for the standard boundary values. For a valid range from minimum to maximum, test minimum minus one, minimum, minimum plus one, maximum minus one, maximum, and maximum plus one.
If asked where Boundary Value Testing is used in APIs, mention numeric fields, string lengths, date validation, pagination, file uploads, request payload sizes, array limits, query parameters, path parameters, and business rule limits.
If asked how BVT differs from Equivalence Partitioning, explain that Boundary Value Testing focuses on edge values, while Equivalence Partitioning tests representative values from groups of valid and invalid inputs. They are often used together.
Interview-Ready Explanation
Boundary Value Testing is a black-box testing technique used to verify how an API or application behaves at the edges of valid and invalid input ranges. Since many defects occur at boundary conditions, testers validate values such as minimum, minimum plus one, minimum minus one, maximum, maximum minus one, and maximum plus one.
This technique helps identify off-by-one errors, incorrect comparison logic, missing validations, overflow issues, and business rule violations. In API testing, Boundary Value Testing is commonly applied to numeric fields, string lengths, dates, pagination limits, file sizes, request payload sizes, array sizes, query parameters, path parameters, and other constrained inputs.
Boundary Value Testing is often used together with Equivalence Partitioning. Equivalence Partitioning reduces the number of test cases by grouping input data, while Boundary Value Testing focuses on the most defect-prone values at the edges of those groups. Together, they provide effective input validation coverage with manageable test effort.
Key Takeaway
Boundary Value Testing helps testers find defects where valid data becomes invalid. It is simple, systematic, and highly useful for API validation. Whenever an API field has a minimum, maximum, length, size, count, date range, or business limit, boundary values should be tested.
For practical API testing, do not rely only on middle-range values. Test the edges: just below the minimum, the minimum, just above the minimum, just below the maximum, the maximum, and just above the maximum. These values often reveal the defects that ordinary positive testing misses.