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.

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?

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

The cinema rule allows 1 to 6 tickets. Which of these is normal data?
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.

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.
ValueShould the program accept it?What it is
-4, “two”NoAbnormal data
0NoBoundary data (just below the smallest acceptable value)
1YesExtreme data, and boundary data
2, 3, 4, 5YesNormal data
6YesExtreme data, and boundary data
7NoBoundary 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

A swimming club accepts whole-number ages from 8 to 16. Which list is the boundary data?
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"
ENDIF

Think 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.

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:

Testing Sam’s program: expected and actual results
Tickets typedExpected resultResult the program givesSame as expected?
3Accepted
1Accepted
6Accepted
0Rejected
7Rejected

    Show the completed table
    Tickets typedExpected resultResult the program givesSame as expected?
    3AcceptedAcceptedYes
    1AcceptedRejectedNo
    6AcceptedRejectedNo
    0RejectedRejectedYes
    7RejectedRejectedYes

    The normal value 3 and the two refused values pass. Only the extreme data, 1 and 6, shows the fault.

    Check your understanding

    Which kind of test data found the fault in Sam’s program?
    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.

    1. State the rule exactly. Whole numbers from 1 to 6 are accepted, and everything else is refused. Each choice below comes from this sentence.
    2. Choose normal data. One or two values from well inside the range. 3 will do.
    3. Choose extreme data. The smallest and largest acceptable values: 1 and 6.
    4. Add the rest of the boundary data. The nearest values outside the range: 0 and 7.
    5. 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.
    6. Write the expected result of every test before running anything. Accepted for the values from 1 to 6, rejected for the rest.
    TestDataType of test dataExpected result
    13NormalAccepted
    21Extreme and boundaryAccepted
    36Extreme and boundaryAccepted
    40BoundaryRejected
    57BoundaryRejected
    6-2AbnormalRejected
    7twoAbnormalRejected
    83.5AbnormalRejected

    Now complete a plan for the swimming club, which accepts whole-number ages from 8 to 16.

    A test plan for the swimming club: whole numbers from 8 to 16
    TestData typedType of test dataExpected result
    112Normal
    28Accepted
    316
    47Boundary
    517
    6-3Rejected
    7tenAbnormal

      Show the completed table
      TestData typedType of test dataExpected result
      112NormalAccepted
      28Extreme and boundaryAccepted
      316Extreme and boundaryAccepted
      47BoundaryRejected
      517BoundaryRejected
      6-3AbnormalRejected
      7tenAbnormalRejected

      Apply it

      A website accepts passwords from 8 to 12 characters. A tester wants the boundary data, written as password lengths. Which lengths should they choose?
      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.

      Show a model answer
      TestDataType of test dataExpected result
      1175NormalAccepted
      2100Extreme and boundaryAccepted
      3250Extreme and boundaryAccepted
      499BoundaryRejected
      5251BoundaryRejected
      6-5AbnormalRejected
      7abcAbnormalRejected
      8(nothing typed)AbnormalRejected

      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

      What is missing from Priya’s plan?
      Show the answer

      Answer: B. The values just outside the range, -1 and 101.

      Test both sides of every limit.

      Apply it

      A tester wants one item of data of the wrong type for the cinema rule, which expects a whole number of tickets. Which should they choose?
      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

      A program passes every test in a well-chosen plan. Which statement is the fairest?
      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).