🔒

Pro Lesson

This lesson is part of the Pro plan. Upgrade to unlock all Cambridge IGCSE lessons.

£7.99/month
or £59/year
Subscribe now →← Back to Dashboard
📘 Paper 2 · Topic 10: Programming
10.2 Testing and Debugging
Cambridge IGCSE Computer Science 0478 · ~15 min read · ⭐ Pro

Types of Errors

Every program can contain errors (bugs). Cambridge IGCSE requires you to identify and distinguish between three types of error.

1. Syntax Error

A syntax error breaks the rules of the programming language. The program cannot run at all — the translator (compiler/interpreter) detects it and stops. Examples: misspelled keywords, missing brackets, incorrect punctuation.

// Syntax errors (Cambridge pseudocode examples)
OUTPU "Hello"          // OUTPU is not a keyword — should be OUTPUT
x = 5                  // Should be x ← 5 (wrong assignment operator)
IF x > 0               // Missing THEN
    OUTPUT x
ENDIF

2. Logic Error

A logic error means the program runs without crashing, but produces the wrong output. The code is syntactically correct but does not do what was intended. These are harder to find.

// Logic error example
total ← 0
FOR i ← 1 TO 5
    total ← i         // BUG: should be total ← total + i
NEXT i
OUTPUT total           // Outputs 5 instead of 15

3. Runtime Error

A runtime error (also called an execution error) occurs while the program is running — after it has started. The program crashes mid-execution. Examples: dividing by zero, accessing an array index that doesn't exist, reading a file that doesn't exist.

// Runtime error example
DECLARE arr : ARRAY[1:5] OF INTEGER
OUTPUT arr[6]          // Runtime error: index 6 out of bounds

result ← 10 / 0       // Runtime error: division by zero
Error typeWhen detectedProgram runs?Example
SyntaxBefore running (by translator)NoMissing THEN, wrong keyword
LogicWhen you check the outputYes, but wrong answerUsing + instead of *, wrong condition
RuntimeWhile runningStarts then crashesDivide by zero, out-of-bounds array

Test Data

Testing uses carefully chosen test data to check that a program works correctly. Cambridge IGCSE requires you to know three types of test data.

Normal (valid) data

Values that the program should accept and process correctly. They are within the expected range.

Boundary (extreme) data

Values at the very edge of the valid range. Boundary data tests whether the program handles the limits correctly. If a program accepts ages 0–120, boundary data would be 0 and 120 (and possibly -1 and 121 as out-of-range).

Erroneous (invalid/abnormal) data

Values that the program should reject — outside the valid range, or the wrong data type entirely. Tests whether the program handles invalid input gracefully.

Test data example — program accepting scores 0 to 100

TypeTest value(s)Expected result
Normal45, 72, 99Accepted and processed
Boundary0, 100Accepted (edge of valid range)
Boundary-1, 101Rejected (just outside valid range)
Erroneous-50, 999, "abc"Rejected with error message

Iterative and Final Testing

TypeWhen doneDescription
Iterative testingDuring developmentTesting each module/subroutine as it is written. Errors are found and fixed immediately before more code is added.
Final testingAfter development is completeTesting the whole program together to check it works as a complete system. Ensures all parts work together correctly.
Exam tip: You will often be given a program and asked to state what type of test data you would use, or asked to identify whether an error is syntax, logic or runtime. Practise with this distinction: syntax = program won't start; runtime = program crashes mid-run; logic = program gives wrong answer but doesn't crash. Always provide three types of test data in test table questions (normal, boundary, erroneous) with expected results.
⚠️ Common Mistakes on Testing Questions
  • Confusing runtime and logic errors — runtime: program crashes; logic: wrong output but no crash
  • Giving only one type of test data — always include normal, boundary AND erroneous
  • Not stating expected results for test data — every test data value needs an expected result
  • Thinking syntax errors can be found by running the program — they stop the program from running at all
  • Only testing boundary = the valid extreme; forgetting to also test the invalid extreme just outside
Video coming soon
Click slide or press arrow keys to navigate
✍️

Worksheet — Testing & Debugging

3 questions · 11 marks

Q1Identify the type of each error and explain why: (a) OUTPUG "Hello" (b) A program divides by a value the user entered which is 0. (c) A loop runs 9 times instead of 10 due to a wrong end value. [6]
✅ Mark scheme
(a) Syntax error [1] — OUTPUG is not a valid keyword, detected by the translator before the program runs [1]. (b) Runtime error [1] — program starts but crashes when dividing by zero during execution [1]. (c) Logic error [1] — program runs without crashing but produces wrong result due to incorrect loop bound [1].
Q2A program accepts a user's age (valid range 16–65). State one example each of normal, boundary, and erroneous test data, with expected results. [3]
✅ Mark scheme
Normal: e.g., 30 → accepted/processed [1]. Boundary: 16 or 65 → accepted; or 15 or 66 → rejected [1] (any valid boundary). Erroneous: e.g., -1, 100, "abc" → rejected with error message [1].
Q3Explain the difference between iterative testing and final testing. State one advantage of iterative testing. [2]
✅ Mark scheme
Iterative testing: testing each module/subroutine during development as it is written [1]; final testing: testing the complete program after development is finished [1]. Advantage: errors are found and fixed immediately before more code is written, making them easier to locate [1].
Quiz — Testing & Debugging
Q 1 of 7
Score
/ 7
Click to reveal
TermDefinition
🎯

Mini Test — Testing & Debugging

10 minutes · mixed marks

← 10.1b Subroutines Topic 10 — Final Lesson 🎉 Dashboard →