QA AND TEST AUTOMATION · PART 1 · MANUAL TESTING, PROPERLY · TECHNIQUE · 10 OF 112

Boundary Value Analysis (BVA) With Examples

Why bugs cluster at the edges of ranges, and how to test them: find each boundary, test the value on it and the values just outside (two-value and three-value BVA), handle money, lengths and dates, and pair it with equivalence partitioning. Worked on ShopRung quantity, SAVE10, free shipping and search length, with the bugs each case catches.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 15

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Test on the edge and just outside
  • 2 or 3 values per edge
  • cents, characters, dates, rounding
  • ask which side

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.

PRICE-3 in code
// 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.

Boundary value analysis
  • 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.

CART-2: quantity 1 to 10
      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.

Three-value BVA
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.

Money boundaries in ShopRung
  • 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

Hidden boundaries

Some boundaries hide inside calculations. Price nine says free shipping depends on the subtotal after the discount. So the edge moves. Four T shirts make eighty dollars, flat five brings it to seventy five, and shipping is free. But the keyboard alone costs exactly seventy five, and with flat five it drops to seventy, so shipping is charged and the total is seventy four ninety nine. Adding a coupon made the customer pay shipping. That is a great case to discuss with the product owner.

Free shipping after discount
  • 4 x T-shirt $20.00 = $80.00
  • apply FLAT5 → $75.00 → shipping free, total $75.00
  • Keyboard $75.00 + FLAT5 → $70.00 after discount → shipping $4.99 → total $74.99
  • the discount moves the edge

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.

Length boundaries
  • 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?

Date boundaries
  • 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.

PRICE-6: nearest cent
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.

Questions BVA raises
  • "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.

Rules of thumb
  • 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.

Avoid these
  • 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.

In the interview
  • "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."

Interview questions

Q1What is boundary value analysis?

A black-box technique that tests the values at the edges of each partition, on the boundary and just outside it, because off-by-one and comparison errors cluster there.

Q2What is the difference between two-value and three-value BVA?

Two-value tests the boundary value and its nearest neighbour across the edge (0, 1 for a minimum of 1). Three-value also tests the neighbour inside (0, 1, 2), catching code that treats the edge specially.

Q3Give boundary values for a password of 8 to 64 characters.

7 and 8 at the lower edge, 64 and 65 at the upper edge (add 9 and 63 for three-value BVA), each with the other rules met.

Q4Why do bugs cluster at boundaries?

Because developers turn rules into comparisons, and it is easy to write > instead of >=, use the wrong constant, or round at the wrong place. Those mistakes only change the result exactly at the edge.

Q5How do you apply BVA to money?

Use the smallest unit, one cent, as the step: $49.99 and $50.00 for a "$50 or more" rule, and include rounding edges such as half a cent.

Q6How do BVA and equivalence partitioning work together?

Partitioning finds the groups and gives one middle value each; BVA adds the edge values of every group. Together they give a small, strong set of cases.

Q7What do you do if a requirement says "orders over $50"?

Ask whether $50.00 itself is included, get the answer written into the requirement, then test $49.99, $50.00 and $50.01.

Q8Do boundaries only apply to numbers?

No. Text length, dates and times, list sizes, file sizes, rate limits and calculated values such as totals after a discount all have boundaries.