Track progress, take quizzes and save notes on this lesson.

Free forever · no card needed

Start free
Intermediate

Testing Programs

2.3.2 Testing

Aligned to the OCR J277 specification

Level
Intermediate
Reading time
8 min
Published
11 June 2026
Updated
1 July 2026
On this page
  1. 1.Why Testing Matters
  2. 2.Iterative and Final Testing
  3. 3.Syntax Errors and Logic Errors
  4. 4.Test Data — Normal, Boundary, Invalid and Erroneous
  5. 5.Writing a Test Plan
  6. 6.Refining Algorithms
  7. 7.Common Exam Mistakes

Key takeaways

  • Iterative testing happens during development, testing each component as it is written so bugs are caught and fixed early; final (terminal) testing happens on the complete program at the end.
  • A syntax error prevents the program from running at all because the code breaks the grammatical rules of the language; a logic error allows the program to run but produces incorrect results.
  • The four test data categories are: normal (valid data in the middle of the range), boundary (valid data at the exact limits), invalid (correct type but outside the range), and erroneous (wrong data type entirely).
  • Boundary values catch off-by-one errors that normal values in the middle of the range will miss; always test both the lower and upper boundaries.
  • A common mistake is classifying erroneous data as invalid: invalid data is the right type but wrong range (e.g. -1 for an age field), while erroneous data is the wrong type entirely (e.g. "hello").

Why Testing Matters

Testing verifies that a program behaves correctly — that it produces the expected output for all possible inputs, including unusual or invalid ones. Without testing, bugs reach users.

OCR J277 covers two aspects of testing: when to test (iterative vs final), and what data to use.

The purpose of testing:

  • Confirm the program does what it is designed to do
  • Find and fix errors (bugs) before the program is released
  • Ensure the program handles invalid input without crashing
  • Provide evidence that the program meets its specification

A program that works for the developer's test cases but fails for users has not been tested thoroughly. The choice of test data determines what errors are found.

Testing can only show the presence of bugs — it cannot prove a program is entirely bug-free. Thorough testing makes it much less likely that bugs remain.

Iterative and Final Testing

Iterative testing happens during development.

(Extra context — OCR J277 uses the term "iterative testing"; "formative" and "modular" are alternative names used in other contexts but are not required OCR terminology.) Each component or subroutine is tested as soon as it is written, before moving on. Problems are caught and fixed early, when they are cheapest to address.

Final (terminal) testing happens when the complete program is finished. The whole system is tested together to ensure all components integrate correctly.

FeatureIterative testingFinal/terminal testing
WhenDuring development, module by moduleAt the end, on the complete program
What is testedIndividual subroutines or componentsThe full integrated system
When errors are foundEarly — easier and cheaper to fixLate — may require rework across modules
What it catchesBugs in individual componentsIntegration bugs and end-to-end behaviour

Worked example: building a quiz program with three subroutines — displayQuestion, getAnswer, and updateScore. With iterative testing, each subroutine is tested immediately after writing. With final testing only, a bug in getAnswer may not be found until the entire program is assembled.

Most real development uses iterative testing throughout, with final testing as a final check before release.

Syntax Errors and Logic Errors

Two error categories arise in programming:

Syntax error — the code breaks the grammatical rules of the programming language. The translator (compiler or interpreter) cannot parse it and the program will not run.

if score > 50    # missing colon — syntax error
    print("Pass")

Logic error — the code runs without crashing, but produces incorrect or unexpected output because the logic is wrong.

if score > 50:    # should be >= 50 for "pass at 50"
    print("Pass")
else:
    print("Fail")

A student with score exactly 50 would be told "Fail". No crash — just wrong output.

Error typeDetectable byEffect
Syntax errorTranslator (at compile/run time)Program will not run at all
Logic errorTesting with appropriate dataProgram runs but gives wrong results

A syntax error prevents execution. A logic error allows execution but produces wrong answers. You cannot find a logic error by reading the error messages — you find it by testing with carefully chosen data.

Test Data — Normal, Boundary, Invalid and Erroneous

Test data is the set of inputs used to test a program. OCR J277 requires knowledge of four categories:

CategoryDefinitionExample (for age input, valid range 0–120)
NormalValid data that the program should accept without errors25, 47, 100
BoundaryValid data at the very edge of the acceptable range0, 120 (the limits themselves)
InvalidCorrect data type but outside the acceptable range — should be rejected-1, 121
ErroneousWrong data type entirely — should be rejected"hello", 3.5, "" (empty)

Why test at the boundary? Boundary values are where off-by-one errors appear. A check written as age > 120 incorrectly accepts 120; a check written as age >= 120 incorrectly rejects 120. Normal values in the middle don't catch this bug — boundary values do.

Something not quite clicking?

Ask Aica to explain any part of this differently. Free, takes 30 seconds.

Ask Aica

Writing a Test Plan

A test plan documents the inputs to be tested, the expected results, and (after testing) the actual results. It provides evidence that systematic testing was carried out.

Worked example — test plan for a program that accepts scores from 0 to 100:

TestTypeInputExpected outputActual outputPass/Fail
1Normal50"Valid score"
2Normal85"Valid score"
3Boundary0"Valid score"
4Boundary100"Valid score"
5Invalid-1"Invalid. Enter 0–100."
6Invalid101"Invalid. Enter 0–100."
7Erroneous"abc"Error or rejection message
8Erroneous45.5Error or rejection message

A complete test plan includes at least one test from each of the four categories. Exam questions often provide a partially completed test plan and ask you to fill in missing entries.

Refining Algorithms

Testing does not just find bugs — it drives algorithm refinement. When a test reveals unexpected output, the algorithm must be revised and re-tested.

Worked example — a sorting algorithm incorrectly handles a list with duplicate values:

Initial test:

  • Input: [3, 1, 2] → Output: [1, 2, 3]
  • Input: [3, 1, 3] → Output: [3, 1, 3] ✗ (duplicates not handled)

The bug is found by testing a case the original developer did not consider. The algorithm is then revised and the test re-run to confirm the fix.

Refined test approach — always include test cases for:

(Extra context — the following edge-case list is good practice but goes beyond the OCR J277 2.3.2 requirement to "identify suitable test data for a given scenario.")

  • Empty inputs (zero items)
  • Lists with duplicate values
  • Lists already in order
  • Lists in reverse order
  • Single-element lists

These represent the edge cases that reveal weaknesses in typical algorithm implementations.

(Extra context — OCR J277 2.3.2 only requires understanding that testing leads to algorithm revision; efficiency and robustness improvements are covered in other spec sections.) Refining algorithms means making them more correct (handles more cases), more efficient (faster or uses less memory), or more robust (handles bad input gracefully).

Common Exam Mistakes

1. Confusing invalid and erroneous test data

Invalid data is the correct type but outside the valid range: for an age field, -1 is an integer (correct type) but invalid. Erroneous data is the wrong type entirely: "hello" is a string, not an integer — erroneous.

2. Forgetting boundary values on both sides

For a range of 0–100, the boundary values are 0 and 100 — both ends. Test both. Students often only test one boundary.

3. Classifying syntax errors as logic errors

If the program will not run, the error is syntax. If it runs but gives wrong output, it is logic. A missing colon in Python is a syntax error; the wrong comparison operator is a logic error.

4. Test plans with only normal data

A test plan that only includes values from the middle of the valid range misses boundary, invalid, and erroneous cases — exactly where bugs are most likely to be. Include all four categories.

MistakeCorrection
Using -1 as "erroneous" data for an age field-1 is invalid (correct type, wrong range); erroneous would be "minus one" or 3.5
Boundary test for range 1–10 uses only 5Boundary values are 1 and 10 — both ends
"Program crashes — that's a logic error"A crash caused by unparseable code is a syntax error

Key terms

Iterative testing
Testing carried out during development, where each component or subroutine is tested as soon as it is written before moving on.
Final testing
Testing carried out on the complete finished program to verify that all components integrate correctly; also called terminal testing.
Syntax error
An error where code breaks the grammatical rules of the programming language; the translator cannot parse it and the program will not run.
Logic error
An error where the program runs without crashing but produces incorrect or unexpected output because the logic is wrong.
Normal test data
Valid input data well within the acceptable range that the program should accept and process correctly.
Boundary test data
Valid input data at the exact edges of the acceptable range, used to catch off-by-one errors in conditions.
Invalid test data
Data of the correct type but outside the acceptable range; the program should reject it. For example, -1 for an age field.
Erroneous test data
Data of the completely wrong type; the program should reject it without crashing. For example, "hello" entered for an age field.
Test plan
A document listing the inputs to be tested, the expected results, and the actual results, providing evidence that systematic testing was carried out.

Frequently asked questions

A syntax error breaks the grammatical rules of the programming language so the program will not run at all - the translator reports it. A logic error allows the program to run but produces wrong output because the logic is incorrect, and it can only be found by testing.

Normal data checks the program handles typical valid inputs. Boundary data checks the exact limits where off-by-one errors appear. Invalid data (correct type, wrong range) checks rejection of out-of-range values. Erroneous data (wrong type entirely) checks the program does not crash on unexpected input types.

Iterative testing tests each subroutine or component during development as soon as it is written, catching bugs early when they are cheapest to fix. Final (terminal) testing tests the complete integrated program at the end to check all components work together correctly.

Generate revision on any topic you study

Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.

Lessons on anything

Structured, level-matched lessons on any topic you study

Practice quizzes

Find out what you actually know before the exam does

Flashcard sets

Lock in key concepts with instant revision cards

Ask Aica

Stuck on something? Get a clear explanation, any time

Prev

Defensive Design

Next

Boolean Logic

Related lessons

7 min

Lesson

Defensive Design

OCR GCSE Computer Science · OCR J277

1 month ago

9 min

Lesson

Sorting Algorithms

OCR GCSE Computer Science · OCR J277

1 month ago

Top students don’t revise more. They revise what counts.

Start revising free

Free to start. No card needed.