📁 Topic 2 · 2.1 Develop Code
2.1 Testing and debugging — error types, test data and trace tables
Edexcel 4CP0 · iGCSE Computer Science · ~11 min read
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

Why Testing Matters

Testing is the process of running a program with carefully chosen data to check that it behaves correctly. A well-tested program should handle normal data, boundary data, and erroneous data correctly. The goal of testing is to find and fix errors before the program is deployed.

Types of Errors

Error TypeWhen it occursExample
Syntax errorDuring translation — breaks language rulesWriting ENDWHILE (no space) instead of END WHILE (correct Edexcel form); missing END IF
Logic errorDuring execution — program runs but gives wrong resultUsing > instead of ≥ in a condition
Runtime errorDuring execution — program crashesDivision by zero; array index out of bounds

Test Data

Good test data covers three categories:

TypeDescriptionExample (age input, valid range 1–120)
Normal (valid)Typical data the program should accept and process correctly25, 40, 67
Boundary (extreme)Values at the edge of what is acceptable — tests the boundary condition1, 120 (just inside); 0, 121 (just outside)
Erroneous (invalid)Data the program should reject — wrong type or out of range"hello", -5, 200, 3.14

Trace Tables for Debugging

A trace table (also called a dry run) is used to track variable values through an algorithm step by step. It helps identify logic errors by showing exactly what the program does at each stage. Create a column for each variable and update values row by row as you execute the algorithm.

Debugging Strategies

  • Desk checking (dry run): Manually trace the algorithm with test values using a trace table
  • Print statements / SEND to DISPLAY: Insert temporary output statements to check variable values at different points
  • Breakpoints: Pause execution at a specific line and inspect variable values in an IDE
  • Stepping through code: Execute one line at a time to observe the effect of each statement
📝 Exam Tip: For "identify a suitable test value" questions, always give at least one normal, one boundary, and one erroneous value. State WHY each value was chosen — e.g., "120 is a boundary value because it is the maximum valid age".
⚠️ Common Mistakes
  • Only giving normal test data — boundary and erroneous data are equally important
  • Confusing a logic error with a runtime error — a logic error produces a wrong answer; a runtime error crashes the program
  • Saying syntax errors occur "when the program runs" — they occur during translation (before running)
Video Coming Soon
This lesson video is being produced
Click slide or press arrow keys to navigate
✍️

Worksheet — 2.1 Testing and Debugging

Answer each question then submit for marking against the Edexcel mark scheme.

Q1State the three types of error that can occur in a program and explain when each occurs.[6 marks]
✅ Mark Scheme
2 marks each:
• Syntax error (1) — occurs during translation / when the code breaks the rules of the language (1)
• Logic error (1) — occurs during execution, program runs but produces incorrect output (1)
• Runtime error (1) — occurs during execution, program crashes / performs an impossible operation (1)
Q2A program asks the user to enter an exam score between 0 and 100. Give one example of each type of test data and explain why each was chosen.[6 marks]
✅ Mark Scheme
1 mark for value + 1 mark for reason, ×3:
• Normal: e.g. 50 (1) — typical valid value to check the program processes it correctly (1)
• Boundary: e.g. 0 or 100 (1) — at the edge of the valid range, tests the boundary condition (1)
• Erroneous: e.g. -1, 101, or "hello" (1) — outside valid range / wrong type, should be rejected (1)
Q3Explain the purpose of a trace table and describe how it is used to debug a program.[4 marks]
✅ Mark Scheme
Mark scheme:
• A trace table is used to track the values of variables as an algorithm executes (1)
• Each column represents a variable; each row represents a step / change in value (1)
• The algorithm is dry-run manually with test data, recording each variable change (1)
• Comparing expected values with actual trace values reveals where a logic error occurs (1)
Q4Identify the type of error in each situation: (a) a program divides by a variable that turns out to be zero; (b) a loop counts from 1 to 9 instead of 1 to 10; (c) a keyword is misspelled as "ENDWILE".[3 marks]
✅ Mark Scheme
1 mark each:
• (a) Runtime error — division by zero causes the program to crash during execution (1)
• (b) Logic error — program runs but the loop count is wrong, producing incorrect output (1)
• (c) Syntax error — misspelled keyword breaks language rules, detected at translation (1)
Quick Quiz
1 / 5
out of 5
Edexcel 4CP0 · Topic 2
Card 1 of 7
Click to reveal
🎉
All cards reviewed!
TermDefinition
Syntax errorAn error caused by breaking the rules of the programming language; detected at translation
Logic errorAn error where the program runs but produces incorrect output due to a flaw in the algorithm
Runtime errorAn error that causes the program to crash during execution (e.g. division by zero)
Normal test dataTypical, valid data the program should accept and process correctly
Boundary test dataValues at the extreme edge of the valid range; tests the boundary condition
Erroneous test dataInvalid data the program should detect and reject (wrong type or out of range)
Trace tableA table used to manually track variable values as an algorithm is dry-run step by step

🎯 Mini Test

Test your knowledge of testing and debugging.

  • 5 questions (3 MCQ + 2 short answer)
  • 10 minutes
  • Edexcel mark scheme feedback
← 1.2 Decomposition and Abstraction Topic 2 · 2.1 Develop Code Next: 2.2 Sequence, Selection, Iteration →
🔒
Pro Content
Subscribe to access all 47 Edexcel iGCSE lessons.
£7.99/month
or £59/year