🔒

Unlock Pro

Subscribe to access all 59 Edexcel 1CP2 lessons.

£7.99/month
or £59/year
🐍 Paper 2 · Topic 6: Programming
6.4b Testing Strategies in Python
Edexcel 1CP2 · GCSE Computer Science · ~11 min read · 🔒 Pro
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

Why Test Programs?

Testing is the process of running a program with specific inputs to check it produces the correct outputs. A well-tested program works correctly under all conditions — not just the ones we expect.

Types of Test Data

TypeWhat it isExample (age field, valid: 0–120)
NormalTypical, expected input within range25, 40, 65
BoundaryValues at the extreme edges of the valid range0, 1, 119, 120
ErroneousInvalid data that should be rejected-1, 121, "hello", 200

Why boundary testing matters: Off-by-one errors are common. A condition written as > instead of >= would fail at exactly the boundary value. Boundary tests catch these precisely.

Types of Errors

Error typeWhen it occursExample
Syntax errorBefore running — code violates Python rulesMissing colon: if x > 0
Runtime errorDuring executionDividing by zero, index out of range
Logic errorProgram runs but gives wrong outputUsing + instead of *, wrong condition

Test Tables

A test table (or test plan) records the tests you run, expected output, and actual output. It's used to document testing systematically.

TestInputExpected outputTypePass/Fail
150"Valid age"NormalPass
20"Valid age"BoundaryPass
3120"Valid age"BoundaryPass
4-1"Invalid"ErroneousPass
5"abc""Must be a number"ErroneousPass

Iterative and Final Testing

Testing should happen throughout development, not just at the end:

  • Iterative testing — test each module/function as it's built; find bugs early when they're easier to fix
  • Final testing — test the complete program at the end against the original requirements
# Example: testing an age validation function def validate_age(age): if 0 <= age <= 120: return True return False # Testing with different data types print(validate_age(50)) # True — normal print(validate_age(0)) # True — boundary print(validate_age(120)) # True — boundary print(validate_age(-1)) # False — erroneous print(validate_age(121)) # False — erroneous
Exam tip: Edexcel often asks you to identify suitable test data for a scenario, or to complete a test table. Always include all THREE types: normal, boundary, and erroneous. For boundary testing, test the exact boundary values AND the values just outside them (e.g. for a 0–120 range: test 0, 1, 119, 120, -1, 121).
⚠️ Common Mistakes
  • Confusing error types — a logic error doesn't crash the program but gives WRONG output
  • Only testing "happy path" (normal data) — boundary and erroneous data must be tested too
  • Testing boundaries incorrectly — for range 0–120, boundaries are 0 and 120 (not 1 and 119)
  • Mistaking a runtime error for a syntax error — syntax errors prevent the program from starting
  • Not using a test table — examiners expect systematic, documented testing
Video coming soon
Click slide or press arrow keys to navigate
✍️

Worksheet — 6.4b Testing Strategies

8 Edexcel-style questions · instantly marked

Q1State the THREE types of test data used when testing a program. For each, give one example for a score field that accepts values 0–100.[6]
✅ Mark scheme
Normal: any typical valid value e.g. 50, 75 [2]; Boundary: extreme valid values e.g. 0, 1, 99, 100 [2]; Erroneous: invalid values that should be rejected e.g. -1, 101, "hello", 200 [2].
Q2Identify the type of error in each: (a) Missing colon after if statement (b) Variable used before being assigned (c) Program calculates 5+3=7 instead of 8[3]
✅ Mark scheme
(a) Syntax error [1] — missing colon violates Python rules, detected before running; (b) Runtime error [1] — NameError occurs during execution; (c) Logic error [1] — program runs without crashing but produces wrong output.
Q3A program accepts a temperature between -50 and 50. What FOUR boundary test values should be used?[4]
✅ Mark scheme
-50 [1] (lower boundary — should be accepted); -51 [1] (just below lower boundary — should be rejected); 50 [1] (upper boundary — should be accepted); 51 [1] (just above upper boundary — should be rejected). These four values target the exact boundary conditions.
Q4What is the difference between iterative testing and final testing?[2]
✅ Mark scheme
Iterative testing: testing each module or small part as it is developed, finding bugs early during development [1]; Final testing: testing the complete finished program against all requirements once development is complete [1].
Q5Complete a test table for a program that checks if a number is between 1 and 10. Include at least 4 test cases covering all data types.[4]
✅ Mark scheme
Normal: 5 → "Valid" [1]; Boundary: 1 → "Valid", 10 → "Valid" [1]; Erroneous (range): 0 → "Invalid", 11 → "Invalid" [1]; Erroneous (type): "hello" → error/rejected [1]. Must include test number, input, expected output, type for full marks.
Q6A function is supposed to square a number but instead returns num*2. What type of error is this and why is it hard to detect?[2]
✅ Mark scheme
Logic error [1]; it is hard to detect because the program runs without crashing and produces output — the output appears plausible but is incorrect. It can only be found by checking actual outputs against expected results [1].
Q7Why is boundary testing particularly important? Give an example of a specific error boundary testing would catch.[3]
✅ Mark scheme
Off-by-one errors are very common in programming [1]; boundary testing checks the exact limits of a condition; example: if a condition uses > instead of >=, then the boundary value (e.g. 0) would be rejected when it should be accepted [1]; testing with exactly 0 would reveal this bug [1].
Q8Explain why testing alone cannot prove a program is completely free of errors.[2]
✅ Mark scheme
Testing can only check the inputs you actually test with [1]; there may be infinite possible inputs and only a finite number of tests — there will always be untested combinations that could reveal bugs [1]. Testing shows the presence of bugs (if they occur), not their absence.
Topic Quiz
Q 1 of 15
You scored
out of 15
Click to reveal definition
🎉
Session complete!
TermDefinition
🎯

Mini Test — Testing Strategies

Timed exam-style test — 10 minutes.

← 6.4a Defensive DesignTopic 6 · PythonNext: 6.4c Dev Lifecycle →