AQA GCSE CSPaper 1 · Unit 2Lesson 14

Paper 1 · Unit 2 · CS-L2-14

Testing & Test Data

60 minutes · AQA 8525 · Paper 1 — Programming

Spec & Goals 3 min

AQA Spec 3.2.11 · Robust and secure programming

By the end of this lesson you can:

  1. Explain why testing makes a program robust.
  2. Choose normal, boundary and erroneous test data for an input.
  3. State the difference between a syntax error and a logic error.

Warm-Up 5 min

Last lesson you wrote validation to reject silly input. Today we test a program to prove it actually works.

Quick starter

A program should accept exam marks from 0 to 100. Which single value is most likely to expose a bug at the edge?

  • 50
  • 100
  • 72
Reveal the answer

100 — it sits right on the edge of what is allowed. Edge values catch "off-by-one" mistakes.

Key Concept — testing and kinds of test data 14 min

Testing runs a program with chosen data to find errors. A well-tested program is robust — it copes with unexpected input without crashing.

Three kinds of test data

For any input you should test all three kinds. They catch different mistakes.

Test dataWhat it is
NormalTypical, valid data the program should accept.
BoundaryValues at the very edge of what is allowed (still accepted).
ErroneousInvalid data the program should reject.

Syntax errors vs logic errors

Two very different kinds of error:

ErrorEffectExample
Syntax errorProgram will not run / translate.Missing a colon or a bracket.
Logic errorRuns, but the output is wrong.Using + where you meant .

A trace table records each variable as the program runs. It is the best tool for hunting a logic error.

Worked Example — test data and a trace table 12 min

Problem: a program accepts a test mark that must be in the range 0–100. Choose test data for it.

KindValue(s)Expected result
Normal57Accepted
Boundary0 and 100Accepted (on the edge)
Erroneous-1 and 150Rejected

Now a buggy routine that should total marks 1, 2 and 3 (answer should be 6):

01  total ← 0
02  FOR i ← 1 TO 3
03      total ← total + i
04  ENDFOR
05  total ← total + 1
06  OUTPUT total

Trace it to find the logic error:

LineitotalOutput
010
0311
0323
0336
0537
06377

The loop already gives 6. Line 05 wrongly adds 1 more, so the output is 7. Removing line 05 fixes the logic error.

The corrected loop in Python

total = 0
for i in range(1, 4):
    total = total + i
print(total)

This corrected version outputs 6 — the loop alone gives the right total.

Try It Yourself 12 min

🟢 Easy

Goal: Give one normal value for an input that accepts a month number 1–12.

Hint: any typical value inside the range works.

🟡 Medium

Goal: For an input that accepts a percentage 0–100, give one boundary value and one erroneous value.

Hint: boundary sits on the edge; erroneous sits outside it.

🔴 Stretch

Goal: Decide whether each is a syntax or logic error: (a) a missing ENDIF; (b) a program that always outputs 'Fail' even for 90%.

Hint: ask whether the program would run at all.

📝 Exam Practice 10 min

Answer the way the examiner expects — the command word and the marks tell you how much to write.

Give[3 marks]

An input accepts ages from 11 to 16. Give one normal, one boundary and one erroneous test value.

Mark scheme
  • Normal: any value 12–15, e.g. 13 (1).
  • Boundary: 11 or 16 (1).
  • Erroneous: any value outside the range, e.g. 10 or 17 (1).
State[2 marks]

State the difference between a syntax error and a logic error.

Mark scheme
  • A syntax error breaks the rules of the language, so the program will not run (1).
  • A logic error runs but produces the wrong result / output (1).
Identify[2 marks]

A field accepts a shoe size from 3 to 12. Identify the kind of test data for the value 12, and for the value 20.

Mark scheme
  • 12 — boundary data (on the edge of the allowed range) (1).
  • 20 — erroneous data (outside the allowed range) (1).

Recap & Key Terms 3 min

Testing finds errors using normal, boundary and erroneous data. A syntax error stops the program running; a logic error gives a wrong result. A trace table helps locate logic errors.

Testing
Running a program with planned data to find errors and check it works.
Normal test data
Typical, valid data the program should accept.
Boundary test data
Values at the edge of the allowed range, which should still be accepted.
Erroneous test data
Invalid data the program should reject.
Syntax error
An error that breaks the rules of the language, so the program will not run.
Logic error
An error where the program runs but produces the wrong result.

Homework 1 min

Task (≤ 15 min): A field accepts a day of the month from 1 to 31. Give one normal, two boundary and two erroneous test values, and say what should happen to each.

Model answer
KindValue(s)Expected result
Normal15Accepted
Boundary1 and 31Accepted
Erroneous0 and 32Rejected

Award marks for: a correct normal value (1), correct boundary values (1), correct erroneous values rejected (1).