← Teacher guide

Testing an algorithm: where does it fail?

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.

Year 9 Space · Geometric algorithms · about 40 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Run 8 min · Investigate 10 min · Modify 10 min · Practise and Make 12 min

Before class

Students need the last lesson.

The one idea: algorithms break at the edges, so tests must include boundary and odd cases. The S >= L fault is deliberate. Lengths are made up.

Running the lesson

  1. Predict: show of hands before the check.
  2. Make: the working is done on paper first.

The hard part (on purpose)

Testing only easy cases. Ask: what is the closest case to the edge of the rule?

When students get stuck

What you will seeA question to askThe fix
A student says all the tests pass.Did you try S equal to L?Add the boundary.

Answers to the checks

  1. which strips break it: The check says triangle when S is greater than OR EQUAL to L. Which strips are most likely to fool it?
    3, 4 and 7. Here S = 7 equals L = 7, so the check says triangle, but the two short strips lie flat along the long one and enclose no space.
  2. the boundary: The strips are 3, 4 and 7. What is S minus L?
    0
    S = 3 + 4 = 7 and L = 7, so S − L = 0: the strips lie flat in a line.
  3. Kinds of test: Which kind of test is 3, 4 and 7?
    A boundary case
    It sits exactly on the edge of the rule (S = L), the place algorithms most often break.
  4. Another boundary: Test 2.5, 2.5 and 5. What is S minus L?
    0
    S = 5 and L = 5, so S − L = 0.
  5. Find the weak point: Ravi tests the checker. Click the line that is the weak point of his testing.
    line 2
    Line 2: three typical cases can all pass while a boundary case fails. Add cases where S equals L, where a length is zero, and where the lengths are equal.
  6. Find the fault: Which set of tests would find the fault in the S >= L check?
    3, 4, 5 and 3, 4, 7
    Only a case with S = L (3, 4, 7) shows the check says triangle when it should not.
  7. Zero length: A strip has length 0. What should the checker say?
    No triangle
    No triangle. A zero-length side cannot be part of a frame.
  8. Another boundary: Strips 1, 1 and 2. What is S minus L?
    0
    S = 2 and L = 2: another boundary case.
  9. Boundary: Test 4, 5 and 9. By how much does S exceed L?
    0
    S = 9 and L = 9: a boundary case.
  10. Is it right: The check S >= L says triangle for 4, 5 and 9. Is it right?
    No: the strips lie flat
    No: S = L means a flat line.
  11. Review: Review: strips 6, 9 and 14. What is S minus L?
    1
    15 − 14 = 1.
  12. test the machine's check: 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.)
    3, 4, 5: 7≥57 \ge 5, triangle: correct (typical); 3, 4, 7: 7≥77 \ge 7, triangle: WRONG (flat) (boundary); 0, 4, 4: 4≥44 \ge 4, triangle: WRONG (zero length) (odd input); 1, 1, 1 correct, 2, 3, 9: 5≥95 \ge 9 is false, correct (the other two)
    Two of the five are wrong: 3, 4, 7 and 0, 4, 4. Both were found only because the test set included an edge case and an odd input.

Stretch and support

Stretch: Design a test set of five cases that finds every fault in a checker.

Support: A printed copy of the situation and a blank table to fill in.

Coach prompt (optional)

For a student who has done the lesson and is still stuck. They paste it into an AI tool your school allows; it asks questions about this lesson's one idea and doesn't give answers. Students see it on the course recap page only through a link ending in ?coach=1: recap with coach prompts.

You are a patient maths coach for a Year 9 student in Australia. Help me understand ONE idea only, from the lesson "Testing an algorithm: where does it fail?".

The idea: Testing an algorithm with cases: I can test an algorithm using specific inputs, identify failure cases, and describe what the algorithm does correctly and incorrectly.

What understanding looks like:
- Tests the algorithm with at least three cases including at least one edge or boundary case
- Records inputs and outputs systematically
- Correctly identifies at least one case where the algorithm fails or produces an unexpected result

Mistakes students often make here:
- A student says all the tests pass.

How to coach me (rules from the Waypoints Kit coach):
- Ask me one short question at a time (2 to 4 sentences) and wait for my answer. Never give me the answer before you have heard my thinking, and don't hide the answer inside your question.
- Start in Discover: ask me to explain the idea in my own words, or to predict what happens in a simple example. I can switch any time: "teach it back" (you play a beginner and I explain), "spot the flaw" (you show me an answer with one common mistake and I find it), or "check" (I explain, and you tell me what is solid and what to revisit).
- If I am stuck or say "just tell me", ask what I think first, then give a small hint or a simpler example. Explain only after I have had a real go.
- If I seem to be missing the idea that comes before this one (Representing a geometric process as an algorithm), check it quickly, then come back.
- Stay in this idea: don't teach later ideas or add extra content. If I ask about something else, say it is for another lesson and bring me back.
- After you help, ask me one reflective question, such as how I know my answer is right or what I would check.
- Praise my effort and method, not my ability.
- You can be wrong: if I rely on something you said, remind me to check it against my notes or the lesson. If you don't know, say so.
- Use simple words.
- Stop when I can explain the idea in my own words and get one new example right. Then tell me to go back to the lesson "Testing an algorithm: where does it fail?".

Exit ticket

Name a boundary case for "S greater than L".

S equal to L, such as 3, 4, 7.

What each step is for

Where it leads

Continues AC9M9SP03 node 2.

Where it leads: refining the algorithm (next).