Community resourceWorksheet
1CP2-CT-9.1 Designing test data and validating behaviour
Part 1 of 4 · 1CP2-CT-9 · Testing, structures and integrated solutions
A test case contains input data, an expected result and a reason. Choose expected results before running the program. Normal valid data checks typical behaviour; boundary data checks exact limits and values just around them; erroneous data violates a requirement and should be rejected.
Students will:
- derive normal, boundary and erroneous tests from requirements
- state an expected result before running a program
- test compound validation rules systematically
- repair validation and rerun relevant tests
Inside: 5 explanation cells, 1 fill-in-the-blanks cell, 3 multiple-choice questions, 2 written answers and 1 Python task. 17 marks, about 45 minutes.
Series: 1CP2-CT-9 · Testing, structures and integrated solutions, part 1 of 4.
Shared by Coding PathwayVerified teacher
- 12 cells
- About 45 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Designing test data and validating behaviour
A test case contains input data, an expected result and a reason. Choose expected results before running the program. Normal valid data checks typical behaviour; boundary data checks exact limits and values just around them; erroneous data violates a requirement and should be rejected.
1. Derive tests from the rule
For the inclusive rule 10 <= value <= 20, 10 and 20 are valid boundary values. Values 9 and 21 are erroneous because they fall outside the accepted interval. A boundary is not automatically invalid.
- boundary
- erroneous
- normal
Which is a complete test case?
- AInput 20 only
- BExpected valid only
- CInput 20, expected accepted, checks the inclusive upper limit
- DRun the program
2. Test compound requirements
A username must contain 5–12 characters and begin with a letter. Test each boundary and each rule independently: a valid 5-character name, valid 12-character name, four characters, thirteen characters and a five-character value beginning with a digit. This makes the cause of failure clear.
Design four tests for an integer mark from 0 to 100 inclusive. Give input, expected outcome and reason for each.
Include normal, both boundaries and an erroneous case.
Students type their answer here.
A program accepts 50 correctly. What does this prove?
- AEvery valid and invalid input works
- BOnly that this test behaved as expected
- CBoth boundaries work
- DThe program has no logic errors
3. Repair validation and rerun tests
The function below should accept values from 1 to 5 inclusive. Its upper comparison is wrong. Amend the condition, then use tests 1, 5, 0 and 6 to protect both endpoints and both rejection paths.
def valid_rating(value):
return value >= 1 and value < 5
low = valid_rating(1)
high = valid_rating(5)
print(low)
print(high)After repairing the condition, state the expected results for inputs 0 and 6 and explain why both should be retained as tests.
Connect each input to a different side of the interval.
Students type their answer here.
When should expected results be written?
- AAfter seeing actual output
- BBefore running the test
- COnly after a failure
- DThey are optional
Route forward
You can derive purposeful tests from requirements. Next you will traverse one-dimensional structures forwards and backwards and justify direction using scenario evidence.