Notes
The problem
Rule price three says save ten works when the subtotal is fifty dollars or more. In code, that is greater than or equal to five thousand cents. Now imagine a developer types greater than instead. The two versions agree on thirty dollars and on eighty dollars. They disagree on exactly one value: fifty dollars. A tester who picks a nice middle value will never see the bug. A tester who tests the edge will see it straight away.
// requirement: $50.00 or more if (subtotal >= 5000) ok // right if (subtotal > 5000) ok // bug // both agree on: // $30.00 refused // $80.00 accepted // they disagree only on: // $50.00 exactly
The idea
A boundary is where the expected behaviour changes, the last value of one partition and the first value of the next. Boundary value analysis says: test the values on each boundary and just outside it. That catches off by one errors, less than written instead of less than or equal, a wrong constant like forty nine instead of fifty, and rounding mistakes at the edge. It works together with equivalence partitioning: partitions find the groups, boundaries test their edges.
- a boundary: where the expected behaviour changes
- test the values ON each boundary and just OUTSIDE it
- why: off-by-one errors, < vs <=, wrong constant, rounding at the edge
- pairs with partitions (EP)
Two-value BVA
The common method is two value boundary analysis. For each boundary, test the value on it and the nearest value on the other side. The quantity range one to ten has two boundaries. At the bottom, zero and one. At the top, ten and eleven. Zero and eleven must be refused, one and ten accepted. Four cases cover both edges. Switch on the ShopRung quantity limit bug and the eleven case fails, while every middle value still passes.
0 | 1 ... 10 | 11 out | in in | out two-value BVA: 0, 1, 10, 11 0 → refused 1 → accepted 10 → accepted 11 → refused 4 cases, both edges covered
Three-value BVA
A stricter version, three value boundary analysis, also tests the value just inside each boundary. For the quantity that adds two and nine. It catches stranger code, where a special case was written for the edge and the neighbour behaves differently from the middle. It costs two more cases per range. Many teams use the two value method by default and three values for money, safety and rules that keep changing. Interviewers like it when you know both.
bottom edge: 0, 1, 2 top edge: 9, 10, 11 catches code like q == 1 || (q > 1 && q < 10) where 2 and 9 behave differently from 5 use it for money, safety, and rules that changed often
Money edges
For money, the nearest value is one cent away, so test forty nine ninety nine and fifty dollars, not forty nine and fifty. ShopRung has three money boundaries: save ten at fifty, flat five at twenty, and free shipping at seventy five. The hard part is building a cart that hits the edge exactly. Four Clean Code Notebooks at twelve fifty make exactly fifty dollars. One hoodie costs forty nine ninety nine. Real testers do this arithmetic before they open the app.
- SAVE10 (PRICE-3) $49.99 refused | $50.00 10% off
- FLAT5 (PRICE-4) $19.99 refused | $20.00 $5 off
- free shipping (PRICE-9) $74.99 → $4.99 | $75.00 free
- build carts from real prices: 4 x Notebook $12.50 = $50.00 1 x Hoodie = $49.99
Lengths
Text fields have length boundaries. ShopRung search must be two to fifty characters, so test one, two, fifty and fifty one. A name is one to fifty characters, so test empty, fifty and fifty one. A password is eight to sixty four, so seven, eight, sixty four and sixty five. Two tips. The rules count characters after trimming spaces, so spaces at the ends do not count. And prepare long strings in a text editor and paste them, because counting while typing goes wrong.
- search (SRCH-3) 2 to 50 1 char refused, 2 searched 50 searched, 51 refused
- name (ACC-2) 1 to 50 0 refused, 50 ok, 51 refused
- password (ACC-5) 8 to 64 7, 8, 64, 65
- count after trimming spaces
- paste long text, do not type
Dates and time
Dates and times are boundaries too. Welcome fifteen expired on the thirty first of December twenty twenty five. Is the thirty first itself still valid? In ShopRung, yes: it is refused from the first of January, using the date in universal time. A login lasts two hours, so a request at one hour fifty nine works and at two hours one minute must ask you to log in again. For every date rule, ask two questions: which time zone, and is the end date included?
- WELCOME15 expired 31 Dec 2025 (PRICE-5)
- is 31 Dec itself still valid? ShopRung: yes, refused from 1 Jan 2026 (UTC date)
- login lasts 2 hours (ACC-7) 1h59m ok | 2h01m expired
- ask: which time zone?
- ask: inclusive or exclusive?
Rounding edges
Rounding creates boundaries too. Price six says a percentage discount rounds to the nearest cent, half a cent rounding up. So ten percent of fifty dollars and four cents is five hundred point four cents, which rounds to five dollars. Ten percent of fifty dollars five is five hundred point five cents, which must round up to five dollars and one cent. The ShopRung rounding bug always rounds down, and only a case on the half shows it.
subtotal 10% expected $50.04 500.4c $5.00 $50.05 500.5c $5.01 bug "discount-rounding" rounds down: $5.00 for both 5 stickers + mouse = $50.45 10% = 504.5c → $5.05 total $50.39
Unclear edges
Boundary analysis often finds problems before any testing starts, because many requirements do not say which side of the edge a value is on. Orders over fifty dollars: does fifty count? Up to ten items: is ten included? Valid for thirty days: from the order or the delivery, and is day thirty included? When you are not sure, ask the product owner, write the answer into the requirement, and then test it. Guessing turns into arguments later.
- "orders over $50 ship free" over = more than? from?
- "up to 10 items" 10 included?
- "valid for 30 days" from purchase or delivery? day 30 included?
- write the answer into the requirement, then test it
Rules of thumb
A few rules of thumb. Every range has two edges, and every edge gets two or three tests. The step size is the smallest unit: one item, one cent, one character, one second. Look for edges in outputs too, like the free shipping line. Combine with partitions: one middle value plus the edges. And when you automate, write the boundary values as rows of data in one parameterized test, which you will do with JUnit later in this track.
- every range has 2 edges
- every edge gets 2 (or 3) tests
- step size = smallest unit: 1 item, 1 cent, 1 char, 1 second
- look for edges in outputs too (free shipping, messages)
- combine with EP: middle value + edges
- automate edges as data rows
Common mistakes
The mistakes to avoid. Using whole dollars when the smallest step is a cent. Testing only the lower edge and forgetting the upper one. Testing just inside and just outside but never exactly on the edge, which is where the greater than bug lives. Building a cart that misses the edge by a few cents. Ignoring boundaries that come from calculations, like after the discount. And assuming whether the edge is included, instead of asking.
- testing $49 and $50, not $49.99 and $50.00
- only the lower edge
- no case exactly ON the edge
- carts that miss the edge by a few cents
- ignoring calculated edges (after discount)
- assuming inclusive/exclusive instead of asking
Say it like this
The classic interview question is an age field that accepts eighteen to sixty. Answer with both techniques. Partitions: below eighteen, eighteen to sixty, above sixty, plus non numbers and empty. Boundaries: seventeen, eighteen, sixty and sixty one, and nineteen and fifty nine with the three value method. Say why: bugs cluster at the edges because less than and less than or equal are easy to swap. And say you would confirm both ends are included.
- "Partitions: below 18, 18-60, above 60, plus non-numeric
- and empty. Boundaries: 17, 18, 60 and 61, and 19 and 59 if I use three-value BVA. Bugs
- cluster at edges because
- < and <= are easy to swap.
- I would also confirm 18 and 60 are inclusive."