🎯 Syllabus & Goals 3 min
Cambridge 7.6 · Suggest and apply suitable test data Paper 2 · Algorithms, Programming and Logic
By the end of this lesson you can:
- Define normal, abnormal, extreme and boundary test data.
- Suggest suitable test data of each type for a given range, with the expected result.
- Build a simple test plan and explain why each item was chosen.
Textbook: Chapter 7, §7.6 (pp. 281–282)
Recap / Warm-Up 5 min
Last lesson, validation rejected unreasonable data. But how do we prove a range check works? We try it with carefully chosen data.
Quick starter
A range check should accept marks 0 to 100. Someone tests it only with 50. Why is that not enough?
Reveal the answer
50 only shows that a typical mark is accepted. It says nothing about −1, 0, 100, 101 or "ten" — where mistakes such as > instead of >= actually show up.
🧠 Key Concept 14 min
1 · Why we test with planned data
A solution must be tested to show it works. Each sub-system is usually tested on its own first. An algorithm is tested by a person working through it (a dry run); a program is tested by running it. Either way, we need data — and the results we expect.
2 · The four types of test data
| Type | Meaning | For marks 0–100 (whole numbers) | Expected result |
|---|---|---|---|
| Normal | data the solution should accept and process | 37, 64, 81 | accepted; correct output |
| Abnormal (erroneous) | data the solution should reject | −12, 150, "ten" | rejected with a message |
| Extreme | the largest and smallest values that normal data can take | 0, 100 | accepted |
| Boundary | at each boundary, the value just accepted and the value just rejected | −1 and 0; 100 and 101 | −1, 101 rejected; 0, 100 accepted |
Worked Example 12 min
Worked example 1 · Test plan for ten exam marks and their average
An algorithm inputs ten percentage marks (whole numbers, 0–100) for one student and outputs the average. Write a test plan.
- Normal: a realistic set with a known answer — 55, 62, 70, 48, 81, 66, 59, 73, 90, 46. Total 650, so expected average 65.all ten 50s would give 50 even if the algorithm divided by the wrong number of marks.
- Abnormal: −12 and "eleven". Expected: both rejected with a message.
- Extreme: 0 and 100. Expected: both accepted.
- Boundary: −1 / 0 and 100 / 101. Expected: −1 and 101 rejected; 0 and 100 accepted.a condition written as
Mark > 0instead ofMark >= 0fails exactly here.
| Test | Type | Test data | Expected result |
|---|---|---|---|
| 1 | Normal | 55, 62, 70, 48, 81, 66, 59, 73, 90, 46 | all accepted; average 65 |
| 2 | Abnormal | −12 | rejected, error message |
| 3 | Abnormal | eleven | rejected, error message |
| 4 | Extreme | 0 | accepted |
| 5 | Extreme | 100 | accepted |
| 6 | Boundary | −1, 0 | −1 rejected; 0 accepted |
| 7 | Boundary | 100, 101 | 100 accepted; 101 rejected |
Worked example 2 · Testing the swimming-pool algorithm
Recall Lesson 3: 1–10 swimmers at $6 each; 10% off for 5–7; 25% off for 8 or more. There are now four boundaries to test — the two range ends and the two discount steps.
| Type | Input | Working | Expected output |
|---|---|---|---|
| Normal | 3 | 3 × 6 | Cost: $ 18 |
| Normal | 6 | 6 × 6 × 0.9 | Cost: $ 32.4 |
| Boundary (lower end) | 0 then 1 | 0 rejected; 1 × 6 | asks again; then $ 6 |
| Boundary (upper end) | 10 then 11 | 10 × 6 × 0.75; 11 rejected | $ 45; then asks again |
| Discount step 1 | 4, 5 | 4 × 6; 5 × 6 × 0.9 | $ 24; $ 27 |
| Discount step 2 | 7, 8 | 7 × 6 × 0.9; 8 × 6 × 0.75 | $ 37.8; $ 36 |
| Abnormal | −3, "six" | outside range / wrong type | rejected |
- Find every boundary in the rules, not just the input range: 1, 10, 5 and 8.an error such as
N <= 5instead ofN < 5only shows at 5. - Test either side of each one and work out every expected cost by hand.
- Notice the surprise: 8 swimmers ($36) cost less than 7 ($37.80). The test data has revealed something the pool manager may want to change — testing checks the rules as well as the code.
Try It Yourself 12 min
Goal: A quiz is now marked out of 20 (whole numbers). Give the extreme data and both boundary pairs, with expected results.
Goal: For the out-of-20 quiz, give two sets of normal data (five marks each) with the expected average, and two items of abnormal data.
Goal: A password must be 8 to 12 characters. Write a full test plan (normal, abnormal, extreme, boundary) with expected results. What is "extreme" for a length?
Hint
Test with passwords whose lengths are 7, 8, 12 and 13 characters. Abnormal data can include an empty entry.
📝 Exam Practice 10 min
Describe each of these types of test data: normal, abnormal, extreme, boundary.
Mark scheme
- Normal — data that should be accepted by the program (1).
- Abnormal — data that should be rejected by the program (1).
- Extreme — the largest / smallest data values that are accepted (1).
- Boundary — the largest / smallest accepted value and the corresponding smallest / largest rejected value (1).
A bill-splitting app works for 2 to 12 diners. Suggest, with expected results: (a) two items of normal data; (b) one item of abnormal data; (c) the boundary data for both ends of the range.
Mark scheme
- (a) One mark per valid item with its expected result, e.g. 4 — accepted (1); 9 — accepted (1).
- (b) e.g. 20, −5 or "three" — rejected (1).
- (c) 1 rejected and 2 accepted (1); 12 accepted and 13 rejected (1).
- Boundary given as pairs, with the accepted / rejected result for each value (1).
Temperatures from −10 to 40 °C (whole numbers) are accepted. Identify the type of test data for each: (a) 40; (b) 41; (c) 18.
Mark scheme
- (a) Extreme (also accept boundary — the accepted value of the pair) (1).
- (b) Boundary (the rejected value) / abnormal (1).
- (c) Normal (1).
🗝️ Recap & Key Terms 3 min
Test with a planned set of data and write the expected result first. Normal data should be accepted; abnormal rejected. Extreme data are the ends of the accepted range. Boundary data test each end with one accepted and one rejected value.
- Set of test data
- All the items of data required to work through a solution.
- Normal data
- Data that is accepted by a program.
- Abnormal (erroneous) data
- Data that is rejected by a program.
- Extreme data
- The largest / smallest data value that is accepted by a program.
- Boundary data
- The largest / smallest value accepted by a program and the corresponding smallest / largest rejected value.
- Expected result
- The result a solution should give for a test, worked out before the test is run.
Homework 1 min
Task (≤ 15 min): A fairground ride accepts children aged over 7 and under 12 (whole years). Complete a test plan with two normal, two abnormal, the extreme and the boundary data, each with an expected result. [6]
Model answer
| Type | Data | Expected |
|---|---|---|
| Normal | 9, 10 | accepted |
| Abnormal | 3, "ten" | rejected |
| Extreme | 8, 11 | accepted |
| Boundary | 7 / 8 | 7 rejected, 8 accepted |
| Boundary | 11 / 12 | 11 accepted, 12 rejected |
Note: "over 7" means 7 itself is rejected, so the smallest accepted age is 8.