GCSE · Computer Science · OCR · Spec J277
Invalid/erroneous test data
You type a silly age into a form and it snaps back "Error!" Broken program, or a program doing its job perfectly?
Computer Science · Testing
Testing an age check: 18 to 65
This program should only accept ages from 18 to 65. Step through three tests. For each one, compare what we expected with what actually happened.
Before you press Next twice: test 2 is going to end in an error message. Pass or fail? Decide now.
1 age = INPUT("Enter your age")2 IF age < 18 THEN3 OUTPUT "Error: age must be 18 to 65"4 ELSE5 OUTPUT "Age accepted"6 ENDIF
| Test | Data | Expected | Actual | Result | Fix |
|---|---|---|---|---|---|
| 1 | 45 | Age accepted | Age accepted | Pass |
Output
Age accepted
Step 1: Normal data first. 45 is between 18 and 65, so we expect it to be accepted. It is. Expected matches actual: pass.
Use Next to run one test at a time. Read the Expected column before you look at Actual.
Three kinds of test data
Sort the test values for the 18 to 65 age check
The program should accept ages from 18 to 65. What kind of test data is each value?
Still to sort
Normal (0)
Valid data the program should accept: the sort of value you'd expect someone to enter.
Where the line is: Normal values sit comfortably inside the range, not on its edge.
Boundary (0)
Values on the edge of being valid: just on or within the edge should be accepted, slightly outside should not.
Where the line is: A boundary value is chosen to test the edge itself, whichever side of it the value lands.
Erroneous (invalid) (0)
Data the program should not accept, because accepting it would cause an error.
Where the line is: This pile is for invalid values that aren't testing the edge at all: data the program should simply refuse.
Pick a value, then pick the kind of test data it is. Watch the two values that both get refused.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Some data should be refused. When the program says no to it, that's not a crash. That's a pass.
What you need to know
- Testing helps you find and fix errors before users experience problems.
- Thorough testing uses a range of data, normal, boundary and erroneous, not just data meant to break things.
- Normal data is valid data the program should accept: the sort of value you'd expect someone to enter.
- If a program accepts ages from 18 to 65, then 45 is normal data, because it's between 18 and 65.
Have a goPick your own normal test value for the 18 to 65 age check, one that isn't 45. How do you know it's normal?
Something like 30: it's between 18 and 65, so it should be accepted.
Any age comfortably between 18 and 65 is ordinary valid data the program should accept, just like 45. That's what makes it normal.
- Boundary data sits on the edge: values on or just within it should be valid, values slightly outside it invalid.
- Erroneous (invalid) data is data the program should not accept, because accepting it would cause an error.
Have a goGrandad types his age as 200 into the 18 to 65 check, "just to see what happens". Should the program let him in?
No. It should refuse 200.
200 is data the program should not accept, so it's erroneous. If the program accepted it, that would be the error, not Grandad's sense of humour.
- Testing that a value outside the allowed range can't be entered? The expected result is an error message.
- A good test plan has clear tests with predicted outcomes, written down before you run them.
- When the actual output matches the expected result, the test passes, even when that output is an error message.
Have a goNo error message, no crash: the age check happily accepts 150. Pass or fail?
Fail.
For erroneous data the expected result is an error message. A calm "accepted" doesn't match what was expected, so the program needs fixing.
- A test table gives each test an ID, description, test data and expected result, then the actual output and any fix.
The big picture
Testing a program thoroughly means using a range of test data: normal, boundary and invalid (erroneous). Erroneous data is data the program should not accept, because accepting it would cause an error. So when you test with it, the expected result is a refusal, such as an error message, and if that is what happens the test has passed. A good test plan writes down each test, its data and its predicted outcome before testing, then records the actual output and, if a test was unsuccessful, how it was fixed.
Key points
Worked example
Problem
A program should accept a test score from 0 to 100. Plan two tests: one with normal data and one with erroneous data. For each, give the test data and the expected result.
⚠ Watch out
Marking a test as failed just because an error message appeared. For erroneous data, the error message IS the expected result, so it's a pass. The failed test is the one where the program quietly accepts data it should have refused.
Memory hook
Expect the "no". When the data is wrong, a program that says no has passed.
Check yourself
Cover the page. A program should accept a number of tickets from 1 to 10. Name one erroneous test value, write its expected result, and say what actual output would make that test fail.
Flashcards
(12)Why do we test programs?
Which three kinds of test data should a thorough test use?
What is normal test data?
What is boundary test data?
What is erroneous (invalid) test data?
A test checks that a user can't enter a value outside the allowed range. What is the expected result?
When does a test pass?
An erroneous-data test ends with the data being accepted. What does that tell you?
What does a good test plan include?
Why isn't a test plan made only of data that breaks the program good enough?
Which four things does a test table specify for each test?
What gets filled in on a test table as the testing is done?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore OCR GCSE Computer Science topics
How this lesson was checked. This OCR GCSE Computer Science (specification J277)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 3 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.