Study Guide
Choosing Test Data
How to decide what to test a program with: normal, abnormal, extreme and boundary test data, why the edges of a rule are where mistakes hide, and how to write a test plan with the result you expect for each test.
Lesson 5.13 Algorithms and Programming
For: Cambridge IGCSE Computer Science learners, or Key Stage 3 learners who can write selection and validation (about ages 13 to 14)
Stage: Think
Six chances to test
The Riverside Cinema (a fictional cinema) has a booking program. A customer may book from 1 to 6 tickets in one go, and the program must refuse any other number. The cinema opens soon, and there is time to try the program with only six different values.
Think it through
Which six values would you type in, and why? Think about what each one would show you.
- Hint 1: Would you test only numbers that a customer is likely to type?
- Hint 2: What other things might a customer type, by accident or on purpose?
Show a model answer
There is no single right set, but a good set includes a typical value such as 3 (a number that should work), the edges of the rule (1 and 6, which should work), values just outside the edges (0 and 7, which should be refused) and something that is not a sensible number at all, such as “two” or -4. Testing only typical values would leave the edges and the silly entries unchecked.
Stage: Discover
Data to accept and data to refuse
Think it through
Your six values fall into two groups: ones the program should accept and ones it should refuse. Which of your values are in each group? Why does it matter to know the answer before you run the program?
- Hint 1: If you did not decide in advance, how would you know whether the program’s answer is the right one?
Show a model answer
Typical values and the edges 1 and 6 should be accepted; 0, 7, -4 and “two” should be refused. It matters because a tester who has not decided in advance can end up believing whatever the program says. A result can only be judged correct or wrong against the result you expected.
Test data is the set of values chosen to test a program, each with the correct result worked out before the test is run. Two kinds are easy to see in the cinema example:
- Normal data is data that the program should accept, taken from well inside the allowed range. For the cinema, 2, 3, 4 and 5 are normal.
- Abnormal data is data that the program should refuse because it is the wrong type, or far outside the allowed range: the word “two”, a negative number such as -4, a decimal such as 3.5, or an empty entry.
Testing is not only about showing that a program works with good data. Half of a good test is checking that the program refuses what it should refuse. A program that accepts 3 but also accepts -4 passes the first test and fails the second.
Check your understanding
Show the answer
Answer: A. The number 4
Normal data should be accepted; abnormal data should be refused.
Stage: Discover
The edges of a rule
Think it through
Mistakes in programs often happen at the edges of a rule. For the cinema rule, 1 to 6 tickets, list every whole number right at the edges, on either side of each limit, and say which the program should accept.
- Hint 1: Look at the lowest limit first: the number itself, and the next number down.
- Hint 2: Then the highest limit: the number itself, and the next number up.
Show a model answer
At the low edge: 0 (refuse) and 1 (accept). At the high edge: 6 (accept) and 7 (refuse). Those four values sit right on either side of the two limits.
Two more kinds of test data look at the edges:
- Extreme data is the largest and smallest value that the program should accept. For the cinema, 1 and 6.
- Boundary data is the largest and smallest acceptable values and the corresponding values just outside them, which should be refused. For the cinema, 1 and 0 at the low end, and 6 and 7 at the high end.
| Value | Should the program accept it? | What it is |
|---|---|---|
| -4, “two” | No | Abnormal data |
| 0 | No | Boundary data (just below the smallest acceptable value) |
| 1 | Yes | Extreme data, and boundary data |
| 2, 3, 4, 5 | Yes | Normal data |
| 6 | Yes | Extreme data, and boundary data |
| 7 | No | Boundary data (just above the largest acceptable value) |
Do not confuse: Extreme data and boundary data
- Which values?Extreme data
- Only the largest and the smallest value that should be accepted.1 and 6
- Which values?Boundary data
- The largest and smallest acceptable values and the nearest values that should be refused.0, 1, 6 and 7
The acceptable edge values are both extreme and boundary data. The values just outside the range are boundary data only.
Check your understanding
Show the answer
Answer: C. 7, 8, 16 and 17
Boundary data comes in pairs across each limit.
This lesson uses whole numbers, so the nearest refused value is 1 away from each limit. For data with decimal places, the nearest refused value depends on how many decimal places are allowed, and exam questions normally use whole numbers.
Stage: Predict
Why the edges catch mistakes
Sam (fictional) writes the cinema’s check, then tests it with the values 3 and 4. Both are accepted, as they should be.
INPUT Tickets
IF Tickets > 1 AND Tickets < 6
THEN
OUTPUT "Accepted"
ELSE
OUTPUT "Rejected"
ENDIFThink it through
Sam says: “It accepts 3 and 4, so it works.” Is that enough evidence? Predict what the program does with 1 and with 6.
- Hint 1: Test the values at the edges: is 1 greater than 1?
- Hint 2: Is 6 less than 6?
Show a model answer
It is not enough, because 3 and 4 are inside the range and say nothing about the edges. The program refuses 1 (1 > 1 is false) and 6 (6 < 6 is false), although the cinema allows both. The comparisons > and < leave out the limits themselves; it should be >= and <=.
Here is what the program really does with five test values. The expected column was decided from the rule before the program was run:
| Tickets typed | Expected result | Result the program gives | Same as expected? |
|---|---|---|---|
| 3 | Accepted | ||
| 1 | Accepted | ||
| 6 | Accepted | ||
| 0 | Rejected | ||
| 7 | Rejected |
Show the completed table
| Tickets typed | Expected result | Result the program gives | Same as expected? |
|---|---|---|---|
| 3 | Accepted | Accepted | Yes |
| 1 | Accepted | Rejected | No |
| 6 | Accepted | Rejected | No |
| 0 | Rejected | Rejected | Yes |
| 7 | Rejected | Rejected | Yes |
The normal value 3 and the two refused values pass. Only the extreme data, 1 and 6, shows the fault.
Check your understanding
Show the answer
Answer: B. Extreme data, because 1 and 6 were wrongly refused.
A mistake in a comparison usually shows only at the values where the comparison changes its answer.
Passing every test does not prove that a program is correct. It shows that the program works for the data that was tried. That is why a test plan includes the edges, where mistakes are most likely, and some data that should be refused. A program that has passed a good plan is more trustworthy, not proven.
Stage: Explain
Building a test plan
A test plan is a table, written before the tests are run, with the test data, why it was chosen and the result expected. Sam’s mistake would have been caught by this one.
- State the rule exactly. Whole numbers from 1 to 6 are accepted, and everything else is refused. Each choice below comes from this sentence.
- Choose normal data. One or two values from well inside the range. 3 will do.
- Choose extreme data. The smallest and largest acceptable values: 1 and 6.
- Add the rest of the boundary data. The nearest values outside the range: 0 and 7.
- Choose abnormal data. Things of the wrong type, or far outside: -2, the word “two” and 3.5. Each one breaks the rule in a different way.
- Write the expected result of every test before running anything. Accepted for the values from 1 to 6, rejected for the rest.
| Test | Data | Type of test data | Expected result |
|---|---|---|---|
| 1 | 3 | Normal | Accepted |
| 2 | 1 | Extreme and boundary | Accepted |
| 3 | 6 | Extreme and boundary | Accepted |
| 4 | 0 | Boundary | Rejected |
| 5 | 7 | Boundary | Rejected |
| 6 | -2 | Abnormal | Rejected |
| 7 | two | Abnormal | Rejected |
| 8 | 3.5 | Abnormal | Rejected |
Now complete a plan for the swimming club, which accepts whole-number ages from 8 to 16.
| Test | Data typed | Type of test data | Expected result |
|---|---|---|---|
| 1 | 12 | Normal | |
| 2 | 8 | Accepted | |
| 3 | 16 | ||
| 4 | 7 | Boundary | |
| 5 | 17 | ||
| 6 | -3 | Rejected | |
| 7 | ten | Abnormal |
- Decide the expected result from the rule, not from any program.
- The smallest and largest acceptable values are extreme data; the values just outside them are boundary data.
Show the completed table
| Test | Data typed | Type of test data | Expected result |
|---|---|---|---|
| 1 | 12 | Normal | Accepted |
| 2 | 8 | Extreme and boundary | Accepted |
| 3 | 16 | Extreme and boundary | Accepted |
| 4 | 7 | Boundary | Rejected |
| 5 | 17 | Boundary | Rejected |
| 6 | -3 | Abnormal | Rejected |
| 7 | ten | Abnormal | Rejected |
Apply it
Show the answer
Answer: D. 7, 8, 12 and 13 characters
Boundary data applies to lengths just as it does to numbers.
Stage: Apply
Write a plan on your own
The school’s lockers are numbered from 100 to 250, and a program must accept only a locker number in that range, as a whole number.
Think it through
Write a test plan with at least eight tests: one normal, two extreme, four boundary (counting the extreme values) and some abnormal data. For each, give the data, its type and the expected result.
Work this out on paper or the board first. Nothing here is marked: compare yours with the model answer.
- Hint 1: Start by writing the rule in a sentence.
- Hint 2: The boundary data comes in pairs: one pair at each end.
Show a model answer
| Test | Data | Type of test data | Expected result |
|---|---|---|---|
| 1 | 175 | Normal | Accepted |
| 2 | 100 | Extreme and boundary | Accepted |
| 3 | 250 | Extreme and boundary | Accepted |
| 4 | 99 | Boundary | Rejected |
| 5 | 251 | Boundary | Rejected |
| 6 | -5 | Abnormal | Rejected |
| 7 | abc | Abnormal | Rejected |
| 8 | (nothing typed) | Abnormal | Rejected |
Other normal values and other abnormal values are equally good. The values 100, 250, 99 and 251 are the ones every plan should contain.
Priya (fictional) is testing a program that accepts exam marks from 0 to 100. Her plan is: normal 50; extreme 0 and 100; boundary 0 and 100; abnormal “abc”.
Apply it
Show the answer
Answer: B. The values just outside the range, -1 and 101.
Test both sides of every limit.
Apply it
Show the answer
Answer: A. The word two
Abnormal data can be the wrong type, or far outside the range.
Stage: Consolidate
Show what you know
Think it through
Explain to a classmate why a tester chooses 0, 1, 6 and 7 for the cinema rule, and does not bother with 2, 3, 4 and 5 as well.
Show a model answer
A good answer says that mistakes in comparisons such as > for >= show up only at the limits, so the values beside each limit (1 and 0, 6 and 7) give the program its hardest tests. The values 2 to 5 behave in the same way as each other, and one of them, such as 3, is enough to show the middle of the range works. Each test also has an expected result that was decided first.
Apply it
Show the answer
Answer: C. It works for the data tried: good evidence, but not proof.
Tests can show that faults exist, but they cannot prove that none remain.
Think it through
Which kind of test data (normal, abnormal, extreme or boundary) do you find hardest to choose? Write one example rule of your own and the data you would pick for it.
Show a model answer
There is no wrong answer. A good example names a rule, such as “a team has 5 to 11 players”, and the data: normal 8; extreme 5 and 11; boundary 4, 5, 11 and 12; abnormal “eight” and -2.
Go deeper Running a test plan in Python
def valid_tickets(tickets):
return 1 <= tickets <= 6
plan = [(3, True), (1, True), (6, True), (0, False), (7, False)]
for value, expected in plan:
result = valid_tickets(value)
print(value, expected, result, "pass" if result == expected else "FAIL")This prints five lines, each ending in pass. If the condition is changed to 1 < tickets < 6, the lines for 1 and 6 end in FAIL, which is how Sam’s mistake shows up. Real programmers keep their test plans as code like this so that the tests can be run again after every change.
- Test data is chosen to test a program, with the correct result worked out before the test.
- Normal data should be accepted. Abnormal data should be refused: the wrong type, or far outside the range.
- Extreme data is the largest and smallest acceptable value. Boundary data is those values and the nearest refused values just outside them (for whole numbers 1 to 6: 0, 1, 6 and 7).
- A test plan lists each test, its type of data and its expected result. Test both sides of each limit, because mistakes such as
>for>=show up only there. - Passing a good plan is good evidence, not proof, that a program is correct.
Sources and scope
- What this lesson is. The thirteenth lesson of the Algorithms and Programming module, written for this site. It covers point 7.6 of Cambridge IGCSE Computer Science 0478 (2026 to 2028, version 6) on suggesting and applying suitable test data. Its curriculum links are provisional and imply no review or endorsement by any examination board.
- Original material. The Riverside Cinema, the swimming club, the lockers, Sam and Priya are fictional, written for this lesson. The pseudocode follows the layout in the syllabus’s pseudocode guide, and each result in a table was worked out by hand.
- Simplified on purpose. The ranges use whole numbers, and the definitions of extreme and boundary data follow the wording of the syllabus’s notes and guidance. Other testing methods are not taught.
- Left to later lessons. Finding and correcting errors in algorithms (Lesson 14), and choosing test data for a whole scenario (Lesson 16).
Test data that a program should reject, such as data of the wrong type or a value far outside the allowed range.
A sequence of precise steps that solves a problem or completes a task.
Test data at the edge of the allowed range: the largest and smallest acceptable values, and the nearest values just outside them, which should be rejected.
The everyday number system with ten digits, 0 to 9, in which each column is worth ten times the column to its right.
Test data that is the largest or the smallest value a program should accept.
Test data that a program should accept, taken from well inside the allowed range.
A precise but language-independent way of writing an algorithm, with set keywords such as IF, WHILE and OUTPUT, that is not tied to any one programming language.
Values chosen to test a program, with the correct result for each worked out before the test is run.
A table, written before the tests are run, that lists the test data to use, the reason for each choice and the result expected.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.