Exit course
Chapter 2 of 9 Beginner 7 min read 2 quick checks Updated

Test Design: Partitions, Boundaries and States

On this page
  1. Equivalence partitioning
  2. Boundary value analysis
  3. State transition testing
  4. Combining the techniques

You cannot test every input. A single text field that accepts up to 50 characters has more possible values than there are atoms in the universe. Test design techniques are how you pick a handful of inputs that are most likely to expose a bug, and how you explain why those and not others. This chapter covers the three you will use every week, each on a real example.

Equivalence partitioning#

The idea: group inputs that the software should treat the same way, then test one value from each group. If the code handles one value in a group correctly, it very likely handles the others the same way; if it is wrong for one, it is probably wrong for all of them.

Example: a shipping rule. The requirement says: "Orders under 50.00 pay 4.95 shipping. Orders of 50.00 or more ship free. The order total must be greater than zero."

Partitions for the order total:

Partition Example value Expected
Invalid: zero or negative -10.00 Rejected (cannot happen in a real cart, but a coupon might cause it)
Valid: below the threshold 23.40 4.95 shipping
Valid: at or above the threshold 82.00 Free shipping

Three tests instead of thousands. Note the first row: invalid partitions matter as much as valid ones, and they are where most of the interesting questions hide. How could an order total be zero or negative? A 100% discount code. A refund applied twice. Asking that question is test design too.

Partitions also exist for things that are not numbers: the type of user (guest, logged in, logged in with a saved card), the payment method, the country. A sign-up form might have partitions for email addresses that are valid, syntactically invalid, already registered, and valid but on a domain the business blocks.

Boundary value analysis#

Bugs cluster at the edges of partitions, because that is where a developer writes < instead of <=. Boundary value analysis tests the values on and right next to each edge.

For the shipping rule, the interesting edge is 50.00. With prices in cents, the boundary values are:

Value Expected Why this value
49.99 4.95 shipping Highest value below the threshold
50.00 Free The threshold itself: "50.00 or more"
50.01 Free Lowest value above it

And at the lower edge: 0.00 (rejected) and 0.01 (accepted, 4.95 shipping).

If the code says total > 50, the 50.00 case catches it. Five values, chosen in two minutes, cover the two places where this rule is most likely to be wrong.

Boundaries hide in places requirements do not mention:

  • Lengths. A name field limited to 50 characters: try 49, 50 and 51, and check what the database column allows, not only what the form says.
  • Dates. The last day of a month, 29 February, the day the clocks change, a date of birth that makes someone exactly 18 today.
  • Counts. An empty cart, one item, the maximum quantity per line, one more than the maximum.
  • Time limits. A session that expires after 30 minutes: act at 29 and at 31.

A password must be 12 to 64 characters long. Which set of lengths is the best choice from boundary value analysis?

Each boundary needs the value on it and the value just outside it: 11 and 65 should be rejected, 12 and 64 accepted. Testing only 12 and 64 never notices a check that wrongly accepts 11 or 65; 1, 30 and 100 are one value per partition, which is equivalence partitioning, not boundary testing.

State transition testing#

Many bugs are not about a single input but about order: doing the right thing at the wrong time. When a feature has distinct states, draw them and test the transitions, including the ones that should be impossible.

Example: an online order. An order can be Placed, Paid, Shipped, Delivered or Cancelled. The business rules say:

  • A placed order can be paid or cancelled.
  • A paid order can be shipped or cancelled (with a refund).
  • A shipped order can be delivered. It cannot be cancelled; the customer has to return it.

Written as a table, with every state against every action:

From \ Action Pay Cancel Ship Deliver
Placed Paid Cancelled not allowed not allowed
Paid not allowed Cancelled + refund Shipped not allowed
Shipped not allowed not allowed not allowed Delivered
Delivered not allowed not allowed not allowed not allowed
Cancelled not allowed not allowed not allowed not allowed

The valid transitions are your happy-path tests. The "not allowed" cells are where the bugs are. Can a customer cancel a shipped order by opening the cancel link from an old confirmation email? Can a warehouse user ship a cancelled order if two people have the order open at once? Does paying twice (double-click on Pay, or Back and Pay again) charge twice?

You do not need to test all twenty cells. Test every valid transition once, then pick the invalid ones that a real user or a race condition could reach: old links, two tabs, Back, refresh, double-click.

Using the order states above, which test is most likely to find a serious bug that the happy-path tests miss?

Cancelling a shipped order is a transition the rules forbid but that a real user can reach through an old link. If the link does not re-check the current state, the shop refunds goods that are already on their way. Placing and paying is the happy path; a different card brand is another partition of payment, not a state problem.

Combining the techniques#

On a real ticket you use them together, in a few minutes, before touching the software:

  1. List the inputs and conditions the feature depends on: fields, user types, settings, states.
  2. Partition each one into valid and invalid groups.
  3. Mark the boundaries between partitions and pick values on and next to them.
  4. Sketch the states if the feature has any, and note the forbidden transitions a user could reach.
  5. Write the result down as a short list of test ideas. That list becomes your checklist (next chapter) or the starting point of an exploratory charter (chapter 3).

When combinations of conditions matter, for example a discount that depends on customer type and basket size and coupon, a small table of the combinations (a decision table) keeps you from missing one. Keep it to the combinations the rules actually distinguish; you are looking for the rule nobody implemented, not for every permutation.

The output of test design is not a document for its own sake. It is the reason you can say, when someone asks, "I tested 49.99, 50.00 and 50.01 because the rule changes at 50", instead of "I tried a few orders and they looked fine."