Why do we test programs, what kinds of testing are there, and what test data should you use?
The purpose of testing, the difference between iterative and terminal (final) testing, and the types of test data (normal, boundary and erroneous or invalid), with how to choose suitable test data.
An OCR J277 2.3.2 answer on testing: the purpose of testing, iterative versus terminal (final) testing, and the three types of test data (normal, boundary and erroneous or invalid), with how to choose suitable test data and build a test plan.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
OCR wants you to explain the purpose of testing, the difference between iterative and terminal (final) testing, and the three types of test data: normal, boundary and erroneous (invalid). You must be able to choose suitable test data for a program and say what each type checks. This is examined in Paper 2, often as a short test plan or a "give an example of each" question.
The purpose of testing
Iterative and terminal testing
Types of test data
A test plan is usually a table:
| Test data | Type | Expected result |
|---|---|---|
| "sunflower9" | Normal | Accepted |
| 6 characters | Boundary | Accepted |
| 5 characters | Boundary | Rejected |
| blank | Erroneous | Rejected |
Try this
Q1. State the purpose of testing a program. [1 mark]
- Cue. To find and remove errors and check the program works correctly, meets its requirements and handles invalid input.
Q2. For a program accepting a number from 1 to 50, give one example each of normal, boundary and erroneous test data. [3 marks]
- Cue. Normal: 25. Boundary: 1 or 50 (or 0 / 51 just outside). Erroneous: 100, or a letter.
Q3. State when iterative testing is carried out. [1 mark]
- Cue. Repeatedly during development, as each part of the program is written.
Exam-style practice questions
Practice questions written in the style of OCR exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
OCR 20214 marksA program accepts a test mark from 0 to 100. Give one example each of normal, boundary and erroneous test data for this program, and explain what boundary test data checks.Show worked answer →
Normal (valid) data (1): a typical value the program should accept, for example 57.
Boundary data (1): a value at the edge of what is allowed, for example 0 or 100 (and just outside, such as -1 or 101). The example 100 is on the boundary.
Erroneous (invalid) data (1): data the program should reject, for example 150, -5, or a letter such as "x".
What boundary data checks (1): it checks that the program behaves correctly right at the limits of the acceptable range, where off-by-one errors are most likely (for example accepting 100 but rejecting 101).
Markers reward one correct example of each type and a clear statement that boundary data tests behaviour at the edges of the valid range.
OCR 20224 marksExplain the difference between iterative testing and terminal (final) testing, and state why testing a program is important.Show worked answer →
Iterative testing (up to 2): testing that is carried out repeatedly during development, as each part of the program is written, so errors are found and fixed early while the code is being built.
Terminal (final) testing (up to 2): testing carried out at the end, on the completed program, to check that the whole program works as a finished product and meets the requirements.
Why testing matters (within the marks): to find and remove errors, to check the program meets its requirements and produces correct results, and to make sure it handles invalid input without crashing.
Markers reward the during-development versus at-the-end distinction and a clear purpose for testing. Saying "iterative is better" misses that they happen at different stages.
Related dot points
- Defensive design: anticipating misuse, input validation and sanitisation, authentication, and writing maintainable programs through comments, indentation and sensible naming.
An OCR J277 2.3.1 answer on defensive design: anticipating misuse, validating and sanitising input, authentication, and writing maintainable programs with comments, indentation and sensible variable names.
- The two main types of programming error: syntax errors and logic errors, what causes each, how they are found, and how they differ.
An OCR J277 2.3.2 answer on the two main types of programming error: syntax errors (breaking the rules of the language) and logic errors (the program runs but gives the wrong result), what causes each, and how they are found and corrected.
- Producing algorithms using pseudocode and flowcharts to solve a problem, identifying the inputs, processes and outputs, and interpreting, correcting and refining algorithms others have written.
An OCR J277 2.1.2 answer on designing algorithms with pseudocode and flowcharts: identifying inputs, processes and outputs, the OCR Exam Reference Language, the standard flowchart symbols, and interpreting, correcting and refining algorithms.
- Using trace tables to determine the output of an algorithm and to follow how the values of variables change, and determining the purpose of a simple algorithm.
An OCR J277 2.1.2 answer on using trace tables to follow an algorithm step by step, record how variable values change, find the output, and determine the purpose of a simple algorithm.
- The three basic programming constructs: sequence, selection (if and switch/case) and iteration (count-controlled for loops and condition-controlled while and do until loops), and when to use each.
An OCR J277 2.2.2 answer on the three programming constructs: sequence, selection (if and switch/case) and iteration (count-controlled for loops and condition-controlled while and do until loops), with the OCR Exam Reference Language for each.
Sources & how we know this
- OCR GCSE (9-1) Computer Science (J277) specification — OCR (2020)