SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
Edexcel 4CP0 · Topic 2 · 2.1

Testing &
Debugging

Types of testing · Test data · Error types · Debugging

CSZone Edexcel iGCSE Computer Science 4CP0
Why Test Programs?

Finding and fixing problems

"Testing is the process of running a program with a range of test data to check it produces the correct output and behaves as expected under all conditions."
GOALS OF TESTING
Verify the program works as intended
Find errors (bugs) before the user does
Confirm the program handles all types of input correctly
IF NOT TESTED PROPERLY
Programs crash with unexpected inputs
Security vulnerabilities left open
Users lose trust / data corrupted
Test Data Types

Three types of test data

Normal (Valid)
Typical, expected input. The program should produce the correct, expected output.
Age: 16, Score: 75
⚠️
Boundary (Edge)
At the very edge of valid range. Tests the limits — both inside and just outside the boundary.
Age: 0, 17, 18, 120
Erroneous (Invalid)
Data the program should reject. Tests that invalid input is handled gracefully with an error message.
Age: -5, "hello", 999
Test Table Example

Testing an age input (valid range: 16–65)

Test dataTypeExpected resultActual result
25NormalAccepted
40NormalAccepted
16Boundary (lower)Accepted
65Boundary (upper)Accepted
15Boundary (just below)Rejected
66Boundary (just above)Rejected
-1ErroneousError message
"abc"ErroneousError message
Types of Errors

Three types of programming error

SYNTAX ERROR
Breaking the rules of the programming language. Caught before the program runs. Example: WHILE x = 5 with no ENDWHILE, or a missing bracket.
LOGIC ERROR
The program runs but produces incorrect output. The code is legal but the algorithm is wrong. Example: using + instead of * to calculate area.
RUNTIME ERROR
The program crashes while running. Often caused by dividing by zero, accessing an invalid index, or running out of memory.
Testing Approaches

White Box vs Black Box Testing

WHITE BOX TESTING
🔍
Tester can see the code. Tests are designed to execute all branches and paths through the code. Also called structural testing. Done by developers.
BLACK BOX TESTING
📦
Tester cannot see the code. Tests based only on the expected inputs and outputs (specification). Done by users or independent testers.
Debugging

Finding and fixing bugs

DEBUGGING TECHNIQUES
Trace tables — manually follow algorithm step by step
Print statements — output variable values at key points
Breakpoints — pause execution at specific lines in a debugger
Code walkthroughs — review code with another person
ITERATIVE TESTING
Test throughout development, not just at the end. Each iteration: write code → test → fix → test again. This catches errors early when they are cheapest to fix.
Exam Practice
Question 1
A program accepts ages between 0 and 120. State one suitable boundary test value and explain why it is a boundary value.
2 marks
✓ MARK SCHEME
1 mark
Any of: 0, 120, -1, 121 (or 1, 119)
1 mark
It is at (or just outside) the edge of the valid range / it is the minimum (or maximum) acceptable value / tests the boundary condition of the validation
Exam Practice
Question 2
State the difference between a syntax error and a logic error. Give an example of each.
4 marks
✓ MARK SCHEME
Syntax def
Breaking the rules of the programming language / prevented from running
Syntax ex.
Missing END IF / misspelled keyword / missing bracket
Logic def
Program runs but gives incorrect results / algorithm is wrong
Logic ex.
Using + instead of * / wrong condition in IF / loop counting wrong number of times
Common Mistakes

Don't lose marks

1
Confusing boundary and erroneous data. Boundary data is at the very edge of the valid range (e.g. age = 0 or 120). Erroneous data is clearly outside/invalid (e.g. age = -5 or "abc").
2
Saying syntax errors happen while the program is running. Syntax errors are caught before execution by the compiler/interpreter. Runtime errors crash the program during execution.
3
Forgetting that boundary testing includes values just outside the boundary. For a range 0–120, you should test -1 and 121 as boundary values, not just 0 and 120.
Topic Summary — 2.1

Key Takeaways

TEST DATA TYPES
Normal — typical valid input
Boundary — at the edges of valid range
Erroneous — data that should be rejected
TESTING TYPES
White box — can see code
Black box — cannot see code (spec only)
ERROR TYPES
Syntax — breaks language rules, stops before running
Logic — runs but wrong output
Runtime — crashes during execution
CSZone

Next Lesson

2.2
Sequence, Selection & Iteration
Program control structures in Edexcel pseudocode
Head to CSZone.co.uk for the full quiz, worksheet and flashcards