A school quiz accepts scores from 1 to 10. How would you catch it letting 11 through?
Your school quiz should accept whole-number scores from one to ten. Suppose someone types eleven and the app accepts it. If you only tried scores you expected to pass, how would you spot that mistake?
Start with a whole-number score. The quiz rule says that one and ten are both allowed, along with the whole numbers between them. You accept a score inside that range and reject a score outside it.
Look at the scores on the number line before you run any code. Zero should be rejected. One, six and ten should be accepted. Eleven should be rejected. Each prediction comes from the rule. We call it an expected result.
The app hasn’t run yet. Use the score rule to predict what should happen when you enter one and when you enter zero. Pick the option that gives the expected result for both scores.
Six is a typical valid score, so it’s normal test data. One and ten are valid, while zero and eleven are invalid. All four test a boundary because they sit at or just outside a limit. Minus twenty is erroneous data chosen to check rejection far outside the range.
Write the rule first: the score is at least one and at most ten. Ten is the maximum, so expect acceptance. Rejection could mean the check excludes ten. Eleven is above the maximum, so expect rejection. Acceptance could mean the upper limit is set too high.
Another quiz accepts whole-number scores from two to eight, including both ends. Pick the two scores that sit either side of the upper cut-off, with the correct expected result for each.
Six can catch a check that accepts only the endpoints. Zero can catch a minimum of zero. One can catch a check that excludes one. Ten can catch a check that excludes ten. Eleven can catch a maximum of eleven. Minus twenty can catch a lower check that only rejects zero.
Suppose one and ten both pass. That looks fine, even if the app wrongly accepts every whole number from zero to eleven. Add zero and eleven to your tests. Both should fail, so acceptance at either end now exposes a fault.
If asked to explain why eleven is useful, say it’s above the maximum and should be rejected. If it passes because the maximum is eleven, that’s a logic error. A missing colon would be a syntax error. Change the upper limit to ten, then rerun all six tests.