The shape of the lesson
By the end of the lesson, learners can
- Choosing test data: In the lab, the age check accepts 11 to 18.
- Strategy and plan: Testing has to be planned during design, before coding starts, so that it is thorough and can be repeated after every change.
- Keeping it working: Programs are often used for years, while bugs surface, laws and hardware change, and users want more.
- Normal: typical, accepted. Abnormal: rejected.
- Extreme: largest and smallest accepted. Boundary: last accepted and first rejected at each limit.
- Test plan: number, purpose, data, type, expected result, actual result.
- Maintenance: corrective fixes, adaptive changes, perfective improves.
One picture every idea returns to
Normal data is typical data that should be accepted. Abnormal (erroneous) data should be rejected: out of range or the wrong type. Extreme data is the largest or smallest value that is still accepted. Boundary data tests each side of a limit: the last value accepted and the first value rejected. A test strategy sets out the overall approach to testing; a test plan lists each test with its data, its type and the expected result. After release a program needs maintenance: corrective (fix errors), adaptive (change it for new requirements or a new environment) and perfective (improve it, for example its speed or ease of use).
Forty-five minutes, phase by phase
| Time | Phase | What happens in the room | Grouping |
|---|---|---|---|
| 0 to 5 min | Hook: predict | Open with the question in the title, Test it, then keep it working.. Good testing is planned, not random. Put the figure on the board: it is the one picture every idea in the lesson returns to. | Whole class, then pairs |
| 5 to 13 min | Teach and check: Choosing test data | In the lab, the age check accepts 11 to 18. Project tab 3 of the lab (Validation and test data) and let a student drive it while the class predicts. Model the worked example Test data for a length check on the board, one line at a time. | Whole class, then pairs |
| 13 to 21 min | Teach and check: Strategy and plan | Testing has to be planned during design, before coding starts, so that it is thorough and can be repeated after every change. Your turn: A test plan for a mark input (0 to 100) has a test with data 101. State its type and expected result. | Pairs |
| 21 to 30 min | Teach and check: Keeping it working | Programs are often used for years, while bugs surface, laws and hardware change, and users want more. Model the worked example Test the amendment on the board, one line at a time. Your turn: Which type of maintenance is the cinema's change? Give a reason. | Think-Pair-Share |
| 30 to 36 min | Check | The four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong. | Individual, then whole class |
| 36 to 43 min | Plenary | The exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording. | Individual, random call |
| 43 to 45 min | Exit and homework | Set the worksheet below (6 questions, 20 marks). Learners self-assess against the objectives before they leave. | Individual |
Protect the parts that carry the learning
The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.
Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.
Cut first if the build overruns: the last check in Keeping it working, never the check or the plenary.
In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.
Think-Pair-Share
Pose the question, give thirty seconds of silent thinking, then a minute to compare with a partner before a few pairs share with the class. The silent minute is the part that cannot be cut.
The full structure, with its variations and the other twelve, is on the cooperative-learning page.
What to head off, and how
| Trap learners fall into | Teaching move that pre-empts it |
|---|---|
| Always give the expected outcome with your test data, and give the actual value, not a description. "A number just outside the range" earns nothing; "11, rejected" does. | Return to Choosing test data: ask a pair to state the correct version and show it on the lab before moving on. |
| The actual result column is empty in the plan: it is filled in when the test is carried out. | Do not confuse the test plan (written in design) with the test results. |
| Corrective maintenance fixes something that was wrong. | If the program was correct but the world or the requirements changed, it is adaptive; if it worked but is being made better, it is perfective. |
Test data and maintenance: worksheet
6 questions, 20 marks. Written in the style of the papers; no past paper question is reproduced.
A program accepts the number of days of a hotel booking: a whole number from 1 to 28. Give one example of normal, abnormal, extreme and boundary test data, with the expected result for each.
Explain the need for a test plan and describe its likely contents.
Describe corrective, adaptive and perfective maintenance.
Identify the type of maintenance in each case. (a) A shop's program is changed to accept a new payment card. (b) A bug that printed the wrong date on receipts is fixed. (c) A menu is redesigned so tasks need fewer clicks.
The function returns the delivery charge for an order:
FUNCTION Delivery(OrderTotal : REAL) RETURNS REAL
RETURN 4.99
ENDFUNCTIONAmend the function so that delivery is free (0) for orders of 50.00 or more, and 4.99 otherwise.
For the amended Delivery function, give three values of OrderTotal that test the condition, with the expected result for each.
Answer key and marking notes
- Normal: e.g. 7, accepted.
- Abnormal: e.g. 40 or −2 or "week", rejected.
- Extreme: 1 or 28, accepted.
- Boundary: e.g. 0 rejected / 29 rejected (with 1 / 28 accepted).
- Needed so that testing is planned, thorough and repeatable, and results can be checked against what should happen.
- Contents: test number, purpose / what is being tested, test data, type of test data.
- Expected result, actual result, pass / fail and any action taken.
- Corrective: fixing errors / bugs found after the program is in use.
- Adaptive: changing the program to meet new requirements or a changed environment (e.g. new law, hardware or operating system).
- Perfective: improving a program that works, e.g. its performance or ease of use.
- (a) Adaptive.
- (b) Corrective.
- (c) Perfective.
- Keeps the header FUNCTION Delivery(OrderTotal : REAL) RETURNS REAL.
- IF OrderTotal >= 50.00 THEN
- RETURN 0 ... ELSE RETURN 4.99 (or assign to a variable and return it).
- ENDIF ... ENDFUNCTION.
- 49.99: 4.99 (just below the limit).
- 50.00: 0 (at the limit).
- A normal value either side, e.g. 20.00: 4.99 or 80.00: 0.
6 multiple-choice questions on this lesson
From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.
Which of these describes a test strategy rather than a test plan?
- AThe overall approach: which testing methods will be used, in what order, by whom and when
- BA numbered list of tests, each with its test data, its type and the expected result
- CA record of the actual results obtained when each planned test was carried out
- DThe set of boundary values chosen for each input that the program has to validate
An input accepts a whole number of years from 18 to 65. Which value is abnormal test data?
- A"thirty"
- B18
- C40
- D65
A bus fare function is being tested.
FUNCTION Fare(Age : INTEGER) RETURNS REAL
IF Age < 16 THEN
RETURN 2.50
ELSE
IF Age >= 60 THEN
RETURN 1.00
ELSE
RETURN 4.00
ENDIF
ENDIF
ENDFUNCTIONWhich test plan entry has the correct expected result?- AAge 16, expected result 4.00
- BAge 15, expected result 4.00
- CAge 60, expected result 4.00
- DAge 16, expected result 2.50
A school's attendance program works correctly. The school replaces its computers with touchscreen tablets, so the program is changed to accept touch input. Which type of maintenance is this?
- AAdaptive
- BCorrective
- CPerfective
- DAcceptance
A password must be from 6 to 12 characters long. Which set of lengths tests both extreme values and the boundary at each limit?
- A5, 6, 12, 13
- B6, 7, 11, 12
- C0, 6, 12, 20
- D5, 7, 11, 13
A shop amends a function so that members get 10% off orders of 20.00 or more.
FUNCTION Charge(Total : REAL, Member : BOOLEAN) RETURNS REAL
IF Total > 20.00 AND Member = TRUE THEN
RETURN Total * 0.9
ENDIF
RETURN Total
ENDFUNCTIONWhich test from the test plan will reveal the error?- ATotal 20.00, Member TRUE, expected result 18.00
- BTotal 25.00, Member TRUE, expected result 22.50
- CTotal 20.00, Member FALSE, expected result 20.00
- DTotal 15.00, Member TRUE, expected result 15.00
Quiz key
The test strategy sets out the overall approach: methods such as white-box, integration, alpha and acceptance testing, their order and who does them. A numbered list of tests with data and expected results is the test plan. Actual results are recorded when the plan is carried out. Boundary values are test data that go into the plan.
"thirty" is the wrong data type, so it must be rejected: abnormal (erroneous) data. 18 and 65 are extreme data, the smallest and largest values still accepted. 40 is normal data, a typical value that should be accepted.
16 < 16 is FALSE and 16 >= 60 is FALSE, so Fare(16) returns 4.00. Age 15 is below 16, so it returns 2.50, not 4.00. Age 60 satisfies >= 60, so it returns 1.00. Expecting 2.50 for 16 treats < as <=.
The program worked, but its environment (the hardware) changed, so it was adapted: adaptive maintenance. Corrective maintenance fixes errors, and there were none. Perfective maintenance improves a working program, such as making it faster, without any change in requirements or environment. Acceptance is a type of testing, not maintenance.
6 and 12 are the extreme values (accepted), and 5 and 13 are the first values rejected on each side, so 5, 6, 12, 13 covers every limit. 6, 7, 11, 12 contains only accepted lengths, so it never checks that anything is rejected. 0 and 20 are well outside the range (abnormal), not next to the limits. 5, 7, 11, 13 misses the extreme values 6 and 12.
For 20.00 with Member TRUE, 20.00 > 20.00 is FALSE, so the function returns 20.00 instead of the expected 18.00: the test fails and exposes the error (it should be >=). 25.00 for a member gives 22.50 as expected. A non-member is never discounted, and 15.00 is below the limit, so both of those tests pass and hide the error.
What to project
The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.
Slides for this lesson
A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.