Good tests include the boundary and the strange cases, not just easy ones. Test the triangle checker on a set of inputs and find where it gives the wrong answer.
The machine's first program says 3, 4 and 7 make a triangle. What would it cut?
A programmer changes the machine's check to "if S is greater than or equal to L, say triangle". It looks fine, so the machine goes into production. Have a guess which three strips would make it cut a frame that cannot close, and we'll come back to the machine at the end.
How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Which strips break it
TryTry it on the board and compare the result with your prediction.
The boundary
The strips are 3, 4 and 7. What is S minus L?
InvestigateWork out why it happens, one step at a time.
Kinds of test case
Worked exampleBefore each step, say what you think comes next.
3,4,5:S=7>5Typical, correct.
3,4,7:S=7=LBoundary, the check says triangle (wrong).
0,4,4:S=4≥4Zero length, the check says triangle (wrong).
Build up to it
Test 2.5, 2.5 and 5. What is S minus L?
Ravi tests the checker. Click the line that is the weak point of his testing.
ModifyChange the problem on purpose and see what happens.
Design tests
Strips 1, 1 and 2. What is S minus L?
PractiseA few on your own, to check you have it.
Run the tests
Test 4, 5 and 9. By how much does S exceed L?
Review: strips 6, 9 and 14. What is S minus L?
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
Test the machine's check
Which kind of test found each fault? Typical, boundary or odd input?
Also used in
Bird keys. A key built for five birds names a common myna (brown, black head, yellow bill) a superb fairy-wren, because nobody tested a bird outside the five. Female fairy-wrens are mostly brown too (Australian Museum: common myna, superb fairy-wren).
Software. Testers deliberately try zero, negative and enormous inputs.
Engineering. A bridge is tested at its limit, not just under normal loads.
Next lesson. Refining the algorithm from the tests and explaining the change.
The check says triangle if S >= L. Run it on these five cases: (3, 4, 5), (3, 4, 7), (0, 4, 4), (1, 1, 1) and (2, 3, 9). How many does it get wrong? (The lengths are made up for the task.)
Work it out on paper first, one step per line. Then type your answer.
Put your page beside this and compare, step by step.
Good tests include the boundary and the strange cases, not just easy ones. Test the triangle checker on a set of inputs and find where it gives the wrong answer. About 40 minutes.