Good test data comes from the specification, not from guessing. Read the rule, find its edges, and choose one input for each kind: normal, boundary and invalid.
This lesson is part of algorithm reasoning and test design. The general idea is also introduced in testing normal, boundary and invalid inputs.
What is the specification?
A school canteen app asks for the number of drink cups a class wants to order. The rule reads: the order must be a whole number from 1 to 40 inclusive, and the program outputs ACCEPTED or REJECTED.
Two phrases carry all the information: “whole number” and “from 1 to 40 inclusive”. Underline them before choosing any data.
How do you find the categories?
Work through the wording in three steps.
- Normal: a value well inside the range, such as 18.
- Boundary: the exact edges, 1 and 40, then the first values outside them, 0 and 41.
- Invalid: values of the wrong kind or plainly impossible, such as 2.5, −7 and the word “ten”.
The word “inclusive” is the trigger. It tells you 1 and 40 must be accepted, so they are valid boundary values rather than invalid ones.
What does the finished test table look like?
| Input | Category | Expected output | Reason |
|---|---|---|---|
| 18 | Normal | ACCEPTED | Inside the range |
| 1 | Boundary | ACCEPTED | Lowest allowed, inclusive |
| 40 | Boundary | ACCEPTED | Highest allowed, inclusive |
| 0 | Boundary (just outside) | REJECTED | One below the minimum |
| 41 | Boundary (just outside) | REJECTED | One above the maximum |
| 2.5 | Invalid | REJECTED | Not a whole number |
| −7 | Invalid | REJECTED | Negative quantity |
| ten | Invalid | REJECTED | Not a number |
Fill the expected column from the specification alone. Only then run the program and compare.
What mistake does this catch?
Suppose the program says IF cups > 1 AND cups < 40 THEN. The normal value 18 passes, so a student who tests one input believes the program works.
The boundary rows expose it. The input 1 gives REJECTED and 40 gives REJECTED, yet the table expects ACCEPTED. Changing the operators to >= and <= fixes both.
Check yourself
A school hall booking form accepts a seat number from 1 to 120 inclusive, whole numbers only. Choose six test inputs with their categories and expected results.
Answer
One good set is:
- 60, normal, ACCEPTED
- 1, boundary, ACCEPTED
- 120, boundary, ACCEPTED
- 0, just outside, REJECTED
- 121, just outside, REJECTED
- 7.5, invalid, REJECTED
Any invalid entry works for the last row, such as −3 or “abc”. The key is that both edges and both values just outside them appear.
What to study next
Next, see how two different algorithms can be judged against the same rule in comparing two algorithms against one contract. Log the test rows you forget using the mistake log and paper-error review.
For a teacher to check your own test plans, see online one-to-one Computer Science tuition.