Community resourceWorksheet

J277 2.3.2 Testing programs and identifying errors

Part 5 of 7 · J277 2.3 · Producing robust programs

What testing is for, how it differs from validation, and how to identify and refine the two types of error.

Students will:

  • state the purposes of testing a program
  • distinguish iterative testing from final testing
  • separate testing from validation
  • tell a syntax error from a logic error
  • refine a program once a fault has been found

Inside: 6 explanation cells, 1 runnable Python task, 2 multiple-choice questions, 1 fill-in-the-blanks cell and 3 written answers. 17 marks, about 45 minutes.

Series: J277 2.3 · Producing robust programs, part 5 of 7.

Shared by Coding PathwayVerified teacher

  • 13 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 17 Aug 2026
  • Updated 9 Sept 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

Testing programs and identifying errors

Testing is the planned process of running a program with selected data, comparing its actual behaviour with the expected behaviour, and refining it when a problem is found.

Testing can be used to:

  • find errors before release;
  • check that requirements have been met;
  • check that expected outputs are produced;
  • discover inputs that make the program fail or behave unexpectedly;
  • provide evidence that refinements have corrected a problem.

Testing is not the same as validation. Validation is code that checks input while a program is being used. Testing is work carried out during or after development to investigate whether the program behaves correctly.

Fill in the blanks3 marks
Complete the distinction. label 1 runs a program with planned data and compares results with expectations. label 2 checks whether input meets acceptance rules while the program is used. label 3 means changing an algorithm to correct or improve it after evidence is found.
  • Testing
  • Validation
  • Refining
  • Authentication
  • Decomposition

Iterative and final testing

Iterative testing during development followed by final testing of the complete program Individual modules are developed, tested and refined in repeated cycles. When the modules have been combined, the complete program receives final or terminal testing before release. Iterative testing during development Develop a module one focused part Test and refine repeat as code develops Final testing complete program after development before release Problems found during development lead back to refinement
  • Iterative testing takes place during development. A module is tested, corrected and tested again as the program is built.
  • Final testing, also called terminal testing, takes place after development. The completed program is tested as a whole before release.

These are types of testing, not types of test data. Normal, boundary, invalid and erroneous describe the data selected for a test.

Multiple choice1 mark

A programmer tests a newly written booking function before combining it with the rest of the system. Which type of testing is this?

  • AFinal testing
  • BBoundary data
  • CAuthentication
  • DIterative testing
Written answer4 marks

Compare iterative testing with final or terminal testing.

Refer to both when it happens and what part of the program is tested.

Students type their answer here.

Syntax and logic errors

A syntax error breaks the grammatical rules of the programming language and stops the program from being run or translated. Examples include a misspelt keyword or a missing colon where Python requires one.

A logic error allows the program to run but produces an unexpected or incorrect result. Examples include adding the wrong value, using the wrong comparison operator or starting a loop at the wrong index.

An example is not a complete definition. “A missing colon” names one possible syntax error, but the definition must mention the language's rules or grammar. “The program does not work” is too vague because it does not distinguish the two error types.

Multiple choice1 mark

Which statement correctly defines a logic error?

  • AThe program runs but produces an unexpected result
  • BThe code breaks the grammar and cannot be translated
  • CThe user enters a value outside a permitted range
  • DA module is tested before the program is complete

Worked refinement

This algorithm should total all values in scores, but its assignment replaces the running total on every repetition:

scores = [4, 7, 5]
total = 0
for score in scores:
    total = score
print(total)

The code runs, so the problem is a logic error. Refining the assignment to total = total + score preserves earlier values and produces 16.

Practical refinement task

Correct the logic error in the supplied program so average is calculated from the total of every score. The checks will also use a different list.

Do not replace the answer with a fixed number. Refine the statement inside the loop so the algorithm works for any supplied list of scores.

Coding task3 marks
scores = [4, 7, 5]
total = 0
for score in scores:
    total = score
average = total / len(scores)
Written answer2 marks

State what is meant by a syntax error and give one valid Python example.

Give the general definition first. The example supports the definition but cannot replace it.

Students type their answer here.

Written answer3 marks

Explain why validation and testing should not be treated as the same process.

Contrast when each happens and what it checks.

Students type their answer here.

Review

Retrieve four precise statements without looking back: the purpose of testing, when iterative testing occurs, when final testing occurs, and the difference between syntax and logic errors. Then check that none of your definitions relies only on an example.