Students run a plant-water alarm against a test table that passes but misses the threshold, learn to choose test cases (either side of the threshold, the threshold itself, the ends), fix an off-by-one, add a steady state, build it on real hardware, and meet a three-band fridge alarm brief against six tests.
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
SlidesDownload Present from the browser, or export to PowerPoint or PDF.
WorksheetDownload Print the student copy; the Teacher edition has the answers.
Students will be able to
I can choose test cases for a brief, including the boundary.
I can fix a sketch until every test passes.
I can explain what passing tests does and doesn't show.
Timing
Predict and Try 6 min · Worked example 10 min · Vary 10 min · Real hardware 12 min · Practise and Make 12 min
Before class
The board's Run the tests runs the sketch once per case with no waiting (3 s of board time each) and records what the first LED did: off (never on), on (came on once and stayed on) or blink (came on two or more times).
This lesson is the Years 9–10 test-case idea (AC9TDI10P06, validate against test cases) met in Years 8–9 hardware; Code's console bridge has the same table-of-inputs idea in Python.
Running the lesson
Try: ask whether 5 out of 5 means the alarm meets the brief.
Worked example: write the table live from the brief.
Vary, three states: ask which case to test first in the if, and why.
The hard part (on purpose)
Students treat 'it worked when I tried it' as done. Ask which reading they tried, and which reading the brief is about.
When students get stuck
What you will see
A question to ask
The fix
A student's steady-on case fails as blink.
Does your steady branch switch the LED off anywhere?
Steady on: HIGH only, no LOW in that branch.
A student changes the tests' expectations in their head.
What does the brief say for 300?
The brief decides, not the sketch.
Answers to the checks
which test finds it?: The sketch says if (level < 300). The brief says 300 or below. Which test reading would show the mistake? 300: the brief wants it to blink, but 300 < 300 is false, so it stays off. Any reading away from 300 behaves the same either way.
Try: run the tests: Run the tests. How many pass? Then look at the readings tested.
All 5 pass, but none of them is 300, the one reading where the sketch and the brief disagree.
A test table: Which set of readings tests this brief best? 0, 299, 300, 301, 1023 Both sides of 300, 300 itself, and the two ends.
Find the mistake: Sam's alarm passed both tests, but stays off at a reading of 300. Click the line where Sam's plan first goes wrong. line 4 Line 4: two far-away tests can't show a slip at the threshold. Sam needs cases at 299, 300 and 301.
Fix the boundary: These tests include 300. Run them, then fix the sketch so all 5 pass.
level <= 300 includes the threshold.
Three states: A new brief: steady on below 100 (very dry), blink from 100 to 299, off from 300. Change the sketch until all 6 tests pass.
if (level < 100) steady on; else if (level < 300) blink; else off. Check the most extreme case first.
A fan: A fan must turn on when the temperature reading is above 600. Which three readings test the threshold? 599, 600 and 601 Just below, at, and just above: 600 itself should be off (above, not at).
All pass: Every test passes. What can you say? The sketch does what those tests check: no more Tests show what they check. A good table covers the boundaries and the ends.
a fridge door alarm: Write the decisions so all 6 tests pass: off below 400, steady on from 400 to 699, blink from 700 up.
Three bands, each edge tested on both sides.
Solutions
One possible solution for each task. Other correct programs are fine.
Vary: change the brief › Fix the boundary
Open task: any program that does what the step asks.
Vary: change the brief › Three states
Open task: any program that does what the step asks.
a fridge door alarm
Open task: any program that does what the step asks.
Stretch and support
Stretch: Stop the flicker near the threshold: switch on at 300 or below, and only switch off again above 320.
Support: A blank test table with columns reading, should do, did, ✓/✗.
Exit ticket
A brief says a buzzer sounds when the reading is 500 or more. Write three test readings for the threshold and what each should do.
499 silent, 500 sounds, 501 sounds.
What each step is for
which test finds it?: Committing to which reading exposes an off-by-one at the threshold tests the new move: the boundary is where the slips are.
Try: run the tests: Every test in this table passes, yet the sketch misses the brief: the table has no case at the threshold. That sets up the method.
Worked example: choose the tests: Building a test table from the brief models the move: one case each side of the threshold, the threshold itself, and the extremes. Sam's two far-away tests are planted after the method.
Vary: change the brief: Each task changes the brief and its tests; students change the sketch until every case passes, including a new steady state.
Build it for real: On real hardware the readings aren't neat: printing them and testing at the edges shows how a real sensor behaves.
tests: Choosing test cases for new briefs, including an inclusive and an exclusive threshold.
a fridge door alarm: Meeting a three-state brief against a full test table brings the unit together: read, decide in bands, act, test.
Where it leads
Next (optional): the same project on a Raspberry Pi Pico. Then Power and motors.