Testing
Iterative and final testing, types of test data and finding syntax and logic errors.
Learning Objectives
- 1Understand the purpose of testing and the difference between iterative and final testing
- 2Identify syntax and logic errors
- 3Select normal, boundary, invalid and erroneous test data for a given scenario
- 4Create or complete a test plan
The purpose of testing
Iterative and final testing
Identifying syntax and logic errors
printt), a missing or extra symbol (bracket, semicolon), mismatched quotes, an invalid variable name (starting with a number or containing a space), a reserved keyword used as a variable (print = 3), wrong capitalisation of a keyword (Print for print), or wrong indentation of a code block. A logic error does not stop the program running, but produces unexpected or incorrect output, e.g. dividing by the wrong variable. Testing is how both types of error get found, syntax errors are usually caught quickly by the IDE, logic errors require careful testing with varied data to expose.Types of test data
Selecting test data and creating a test plan
def validate_age(age):
if age < 0 or age > 120:
return "Invalid"
return "Accepted"function validateAge(age)
if age < 0 OR age > 120 then
return "Invalid"
endif
return "Accepted"
endfunctionExam Phrasing: Use These Exact Phrases
- ✓Testing aims to find errors, not just to show a program works
- ✓Iterative testing happens throughout development, testing individual modules; final testing happens once the whole program is complete
- ✓A syntax error breaks the rules of the language and stops the program running; a logic error produces unexpected output
- ✓Normal and boundary data should be accepted; invalid and erroneous data should be rejected
- 💡When a question asks for test data, give a specific value for the type asked (e.g. an actual boundary number), not just the word "boundary".
- 💡Never describe an error as the program "not working" or "stopping working", examiners mark that as too vague. Say what actually happens: it will not run or translate at all (syntax), or it runs but gives the wrong result (logic).
- 💡A problem with a data type is not accepted as an example of a syntax error, and "incorrect grammar" on its own is not enough. Give a concrete example instead.
- 💡Invalid and erroneous data are defined separately in the spec (invalid = correct type, wrong range; erroneous = wrong type entirely), but exam questions usually just group both as data that should be rejected.
- 💡Justify your test data using the scenario given, e.g. explain why a specific boundary value matters for that particular input.
- 💡Don't confuse iterative testing (during development, testing modules) with final testing (testing the whole finished program).
Wrong:
Boundary data is just another example of normal data
Right:
Boundary data sits exactly on the edge of the valid range, and is a distinct, specifically named category
Why it matters: Boundary values are the values most likely to reveal an off-by-one logic error (e.g. using > instead of >=).
Wrong:
Testing is about proving the program works
Right:
Testing should be approached destructively, actively trying to find errors
Why it matters: A program can pass a few easy tests and still contain bugs that only appear with less obvious data.
Wrong:
Invalid and erroneous data mean exactly the same thing
Right:
Invalid data is the correct type but out of range; erroneous data is the wrong type entirely
Why it matters: This is a real distinction in the specification, even though exam questions often group them together as "rejected" data.
Question:
A program accepts a percentage score from 0 to 100. State one example each of normal, boundary, invalid and erroneous test data for this input. [4]
💡 Attempt this before revealing the answer, practice makes perfect!
Model Answer:
Normal data: 75, a typical, sensible score within range. Boundary data: 0 or 100, right on the edge of the valid range. Invalid data: -5 or 101, the correct data type (a number) but outside the valid range. Erroneous data: "high", the wrong data type entirely (text instead of a number).
Mark Scheme:
- 1Correct normal data example, a sensible value between 0 and 100
- 2Correct boundary data example, exactly 0 or exactly 100
- 3Correct invalid data example, a number outside 0 to 100
- 4Correct erroneous data example, non-numeric data
Tap a card to flip it. Use the arrow keys to move and space to flip.
Exam-style questions. Have a go, then reveal the mark scheme to check your answer.
1.Explain the difference between iterative testing and final testing.
[2]2.A program runs without crashing, but always calculates the wrong average. State whether this is a syntax error or a logic error, and explain your answer.
[2]3.Explain why boundary data is important to include when testing a program.
[2]4.Complete a test plan entry for testing the function below with the input -5. State the test data type, the expected result, and explain your reasoning.
[3]def validate_age(age):
if age < 0 or age > 120:
return "Invalid"
return "Accepted"function validateAge(age)
if age < 0 OR age > 120 then
return "Invalid"
endif
return "Accepted"
endfunction5.A program should accept whole numbers from 1 to 20. Give one example each of normal, boundary, invalid, and erroneous test data for this input.
[4]6.A program accepts a whole number between 1 and 100. Describe a test plan for this program, explaining the purpose of each type of test data you would use.
[6]The examiners' reports are the most useful and least read of the three: they say what candidates actually got wrong each year. All files are hosted by OCR.
Past-paper questions grouped by topic
The same OCR questions, sorted by topic rather than by year (via Physics & Maths Tutor).
A question testing understanding of test data types (normal, boundary, invalid/erroneous) was answered very well by the vast majority of candidates, showing this topic is generally well taught. Examiners specifically noted that although the specification defines invalid data and erroneous data as separate categories, exam questions consistently group them together as data that a system would reject.
Candidates who did less well on the paper commonly confused the concept of maintainability (2.3.1) with testing (2.3.2), these are two distinct required topics and should not be conflated: testing checks a program works correctly, maintainability is about how easy the code is to read and modify.