Boundary value analysis and equivalence partitioning, with examples
Equivalence partitioning splits all possible inputs into groups the software should treat the same way, so one value from each group is enough to test. Boundary value analysis then tests the edges of those groups, because that is where rules are most often coded wrong. For a field that accepts whole numbers from 1 to 10, partitioning gives three groups (below 1, 1 to 10, above 10), and the boundary values to test are 0, 1, 10 and 11, or 0, 1, 2, 9, 10 and 11 with the 3-value method.
- 2 techniques
- used together, one after the other
- 4 worked examples
- quantity, stock, money, length
- 2-value and 3-value
- both methods, and when to use which
How to apply both, step by step
- Step 1
Write down the rule
Note the exact limits, the step of the value and what should happen outside the limits. If the requirement does not say, ask; do not invent a limit.
- Step 2
Split the inputs into partitions
Valid partitions hold values the software should accept; invalid ones hold values it should refuse. Add wrong types, the empty value, and valid partitions with different outcomes.
- Step 3
Take one value from each partition
Any value inside a partition should behave like the others, so one representative is enough. More values from the same partition add time, not information.
- Step 4
Find the boundary values
For every ordered partition (numbers, lengths, money, dates), the smallest and the largest values are its boundaries. Partitions of letters or categories have none.
- Step 5
Add the neighbors at the right step
The step is the smallest change the field allows: 1 for whole numbers, 0.01 for money. Take one neighbor with the 2-value method, both neighbors with the 3-value method.
- Step 6
Write the expected result for every value
Decide what should happen before you run anything, from the requirement. A test without an expected result cannot fail.
- Step 7
Test invalid values one at a time
Two invalid values in one test can hide each other: when the form refuses it, you cannot tell which value caused the refusal.
What equivalence partitioning is
You cannot try every value a field accepts. Equivalence partitioning answers which ones to try: group values the software should treat the same way, and test one value per group. If one value of a partition finds a defect, any other value of that partition should find it too. Partitions are also called equivalence classes.
Invalid partitions are wider than "too small" and "too large". A field for numbers can also receive letters, symbols, a decimal, pasted text or nothing at all. Every partition, invalid ones included, gets at least one test. Test the empty value and zero separately even when they seem covered: the check for empty input is often separate code.
What boundary value analysis is
Developers most often make mistakes at the edges: "less than" written instead of "less than or equal to", a limit moved by one. Boundary value analysis tests the smallest and largest value of each ordered partition and the values next to them.
The 2-value method tests each boundary value and its closest neighbor in the next partition. The 3-value method adds the neighbor on the inside as well. The 3-value method is stricter: if "up to 10" was coded as "exactly 10", the 2-value set (10 and 11) passes, while the 3-value set adds 9 and catches it. Both are standard; in a test assignment, say which one you used.
Example 1: a quantity from 1 to 10
Shelf is the practice shop the courses use. On a product page, Quantity accepts a whole number from 1 to 10 per product. Take the Hearthline Classic Kettle 1.7 l: USD 49.00, 34 in stock, so stock is not a limit here.
Notice that 11 appears twice in the analysis: it is a neighbor of the valid partition's upper boundary and, at the same time, a member of the invalid partition "11 and above". Values shared by two checks are tested once; note in your test set that the duplicate was removed on purpose.
Rule: Quantity is a whole number from 1 to 10 per product. Partition Value Expected below 1 (invalid) 0 refused 1 to 10 (valid) 3 added to the cart above 10 (invalid) 12 refused not a whole number 2.5 refused letters abc refused empty (none) refused Boundary values, 2-value: 0 1 10 11 Boundary values, 3-value: 0 1 2 9 10 11
Example 2: a limit that depends on the data
Some boundaries are not written in the field; they come from data. The Pedalwise Gravel One costs USD 1,249.00 and has 4 in stock, so for this product Quantity splits differently: 1 to 4 is valid, and 5 to 10 is a separate invalid partition with its own message, "Only 4 left in stock." The boundary values are 4 and 5, and they move whenever the stock changes.
The cart adds another data-driven limit. No more than 10 of one product may be in the cart in total, so with 8 kettles already there, adding 3 should be refused with "You can add up to 10 of one product.", while adding 2 should pass. The same field now has its boundary at 2 and 3.
Example 3: money and a threshold
Shelf charges USD 4.99 for shipping and ships free when the subtotal is USD 50.00 or more. Both partitions are valid; they differ in outcome. The step for money is 0.01, so the values around the boundary are USD 49.99, USD 50.00 and USD 50.01, never 49 and 51.
You can build the first two carts from the catalog. Maps of Quiet Places (USD 9.99), Tea Around the World (USD 21.00) and Asking Better Questions (USD 19.00) make USD 49.99: by the rule, shipping is USD 4.99 and the cart says "Add USD 0.01 more for free shipping." Swap the first book for Counting Sheep (USD 10.00) and the subtotal is exactly USD 50.00, where shipping should be free. No combination of the shop's products adds up to exactly USD 50.01, so that neighbor needs a product whose price you control, for example one created through the shop's API.
Example 4: the length of a text field
Boundary values work for the length of text, not for the letters in it. Shelf's sign-up form takes a username of 3 to 15 characters (letters, digits or _) and refuses anything else with "Use 3–15 characters: letters, digits or _." The password takes 8 to 72 characters, with the message "Use 8 to 72 characters."
Describe each value by its length and type rather than by a literal string, and test a wrong type inside the valid length, such as 5 characters with a space in the middle: then only the type check can refuse it. A 16-character name with a space would break two rules at once.
Username, 3 to 15 characters 2-value: 2 3 15 16 3-value: 2 3 4 14 15 16 separately: empty; 5 characters with a space inside Password, 8 to 72 characters 2-value: 7 8 72 73 3-value: 7 8 9 71 72 73
Common mistakes
These come up in almost every first attempt and in interviews. Each one either misses the value where the defect sits or spends tests on values that cannot find anything new.
"The lower boundary of 1 to 10 is 0"
1 is the boundary value. 0 is its neighbor, and it belongs to the invalid partition.
Neighbors at the wrong step
For a price from USD 9.99, the neighbors are USD 9.98 and USD 10.00, not 9 and 11.
Boundaries for letters
"a" and "z" are not boundaries. Use the technique for ordered values: numbers, lengths, money, dates.
No limit in the requirement
There still is one: the size of the data type, a database column, a browser limit. Ask for it to be written down.
Five values from one partition
They find the same defects as one. Spend the tests on another partition instead.
Two invalid values in one test
A 2-character username and a 7-character password in one sign-up: the refusal does not tell you which rule worked.
Where to learn this
Questions and answers
What is the difference between equivalence partitioning and boundary value analysis?
Equivalence partitioning chooses groups of values that should behave the same and tests one value from each. Boundary value analysis takes the ordered groups and tests their edges and the values next to them. Partitioning comes first; boundaries are built on its result.
Should I use 2-value or 3-value boundary analysis?
Both are correct. The 3-value method costs a few more tests and catches a boundary coded as an exact match. Use it where a defect would be expensive, and always state which method you used.
How many test cases does equivalence partitioning give?
At least one per partition, invalid partitions included. Test invalid partitions one at a time, so a field with one valid and four invalid partitions needs at least five tests.
Is 0 a boundary value for a field that accepts 1 to 10?
No. The boundary values of the valid partition are 1 and 10. 0 and 11 are their neighbors, which you also test, and each belongs to an invalid partition.
Does boundary value analysis work for text fields?
For their length, yes: 3 to 15 characters gives boundaries at 3 and 15 and neighbors at 2 and 16. For the letters themselves, no, because letters are not an ordered range for this technique.
What if the requirement gives no upper limit?
There is one anyway: the data type, the database column or a browser limit. Try growing values to find it, and ask for the limit to be written into the requirement.
More guides
- Start hereHow to become a software testerWhat a software tester does, what to learn and in what order, and how to practice without a job: six steps from zero to a small portfolio.
- Bug reportsHow to write a bug reportThe fields of a bug report, a template to copy, a complete example from a practice shop, severity and priority with examples, and the mistakes that send a report back to you.
- Test casesHow to write test casesThe parts of a test case, a template, a complete example and its negative cases, the difference between a test case, a test scenario and a checklist, and how to fix a weak case.
- Bug reportsSeverity vs priority, with examplesWhat severity and priority mean, who sets each, the scales teams use, and all four combinations worked through on one practice shop, with a short answer for interviews.
- Test documentationTest case vs test scenario vs checklistWhat a test scenario, a checklist and a test case are, one shop feature written all three ways, when to use which, and how a scenario turns into checklists and test cases.
- Test designHow to test a login pageTest cases for a login page derived from partitions, a decision table, boundaries and states, plus the security checks every login page needs, worked through on a practice shop.
- API testingAPI testing with Postman: a beginner's guideHow to send your first requests in Postman, read the response, keep addresses and tokens in variables, test 401 and 403, add a status check and run a collection, on a practice shop's API.
- API testingHow to test a REST API manually: a checklistA manual REST API testing checklist without code: reading the OpenAPI documentation, status codes, body, headers, 401 versus 403, negative cases and state, with example requests to a practice shop.
- DatabasesSQL for testers: check what the app savedHow testers use SQL: the queries that check what an online shop saved after an order (order row, items, payments), SELECT, WHERE, GROUP BY and JOIN on a real schema, and the mistakes to avoid.
- Web testingChrome DevTools for testers: how to collect evidence for a bug reportWhich Chrome DevTools panels a tester needs and how to use them to collect the Console error, the request, the server's response and the storage values that make a web bug report reproducible.
- Test processSmoke vs sanity vs regression testingWhat smoke, sanity, regression testing and retesting usually mean, why teams use the names differently, how to ask on a new team, and how to choose the checks for a new build.
- Mobile testingHow to test a mobile appWhat breaks only on a phone, how to choose between an emulator, a simulator and a real device, how to read the app's log and its traffic through a proxy, and a checklist to start from.
See the first course
The full outline of every course is available: you can see each lesson before you start.
