Testing, Errors & Test Data
Find defects systematically and choose test data that checks the full valid range.
Testing should happen during development and again when the completed program is ready. Test data should include normal, boundary, invalid and erroneous cases.
Predict
Read the code first. Do not run it yet.
age = 16
if age > 16:
print("Allowed")
else:
print("Not allowed")- What is printed?
- If the intended rule is “16 or over”, is there a logic error?
- Which operator should be changed?
Investigate
Use this code to explain exactly how the program works.
minimum = 1
maximum = 100
value = 100
valid = value >= minimum and value <= maximum
print(valid)- Is 100 normal or boundary test data for the valid range 1 to 100?
- What other boundary value should be tested?
- Give one invalid value of the correct type and one erroneous value of the wrong type.
Syntax and logic errors
| Error type | Meaning | Example |
|---|---|---|
| Syntax error | Breaks the grammatical rules of the language and prevents correct translation/execution | missing colon after an if statement |
| Logic error | The program runs but produces an unexpected result | using > when >= was required |
Test-data categories
| Type | Meaning | Example for valid age 11–16 |
|---|---|---|
| Normal | valid data comfortably inside the allowed range | 14 |
| Boundary | valid data at the edge of the allowed range | 11 or 16 |
| Invalid | correct data type but should be rejected | 10 or 17 |
| Erroneous | incorrect data type and should be rejected | "twelve" |
Testing during and after development
Iterative testing checks modules and changes while the program is being developed. Final/terminal testing checks the completed program at the end of development.
| Input | Type | Expected result | Actual result | Pass? |
|---|---|---|---|---|
| 14 | Normal | Accepted | Accepted | Yes |
| 11 | Boundary | Accepted | Accepted | Yes |
| 10 | Invalid | Rejected | Rejected | Yes |
| "twelve" | Erroneous | Rejected | — | To test |
Self-study guide
Testing checks whether a program behaves as intended and helps programmers find defects before the program is trusted. OCR requires the purpose of testing, iterative and final/terminal testing, syntax and logic errors, normal/boundary/invalid/erroneous test data, refining algorithms, and the ability to create or complete a test plan.
Testing is strongest when data is chosen deliberately. Randomly trying a few values is much weaker than selecting values because each one challenges a specific rule or boundary.
OCR Exam Reference Language ↔ Python
| OCR Exam Reference Language / term | Python | What to remember |
|---|---|---|
Syntax error | e.g. missing Python colon | Breaks grammatical rules and stops the program being run/translated normally. |
Logic error | e.g. `>` instead of `>=` | Program runs but produces unexpected/incorrect output. |
Iterative testing | testing modules during development | Used while developing and refining. |
Final / terminal testing | testing completed program at end | Checks the complete product. |
Normal data | valid ordinary value | Should be accepted without causing errors. |
Boundary data | valid value at edge | Correct type and on the very edge of validity. |
Invalid data | correct type, should be rejected | Outside the accepted rule. |
Erroneous data | incorrect data type, should be rejected | Wrong type for the expected input. |
Worked example
A test plan makes the expected result explicit before the program is executed.
def valid_score(value):
if type(value) != int:
return False
if value < 0 or value > 100:
return False
return True
test_data = [50, 0, 100, -1, 101, "fifty"]
expected = [True, True, True, False, False, False]
for index in range(len(test_data)):
actual = valid_score(test_data[index])
passed = actual == expected[index]
print(test_data[index], expected[index], actual, passed)50 True True True 0 True True True 100 True True True -1 False False True 101 False False True fifty False False True
- 50 is normal valid data.
- 0 and 100 are valid boundary values.
- -1 and 101 are invalid because they have the correct numeric type but are outside the valid range.
"fifty"is erroneous because the program expects an integer but receives a string.- The expected result is decided before execution; the actual result is recorded after execution.
passedshows whether actual behaviour matches the expectation.
Another example
Boundary data is especially effective at exposing comparison mistakes.
total = 30
if total > 30:
print("Free delivery")
else:
print("Delivery charge")Delivery charge
- If the rule says 30 or more should receive free delivery, the program contains a logic error.
- The boundary value 30 exposes the error immediately.
- The condition should be
total >= 30.
Common mistakes
- Calling a logic error a syntax error just because the answer is wrong.
- Calling invalid numeric data “erroneous”; OCR defines erroneous data as the wrong data type.
- Using only normal data and forgetting boundaries.
- Writing test data without an expected result, making it harder to decide objectively whether the test passed.
- Confusing iterative testing during development with final/terminal testing after production.
Exam-ready checklist
- Define syntax and logic errors precisely.
- Distinguish iterative from final/terminal testing.
- Choose normal, boundary, invalid and erroneous data for a scenario.
- Create/complete a test plan with expected and actual results.
- Use failed tests to refine an algorithm or program.
What you have learned
- Syntax errors break language rules; logic errors produce unexpected results.
- Use normal, boundary, invalid and erroneous test data.
- Iterative testing happens during development; final/terminal testing happens at the end.
- A test plan records inputs, expected results, actual results and whether each test passed.