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 THEN
3 OUTPUT "Error: age must be 18 to 65"
4 ELSE
5 OUTPUT "Age accepted"
6 ENDIF
TestDataExpectedActualResultFix
145Age acceptedAge acceptedPass

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.

1 / 3

Use Next to run one test at a time. Read the Expected column before you look at Actual.

Step 1 of 3: Normal data first. 45 is between 18 and 65, so we expect it to be accepted. It is. Expected matches actual: pass..

Exam line: Erroneous data should be refused, so the expected result of the test is an error message. Matching it is a pass.
Watch out: "Error message" in the Actual column is not automatically bad news. Check the Expected column first: if an error message was what you predicted, the test passed.

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.

6 of 6 still to sort.

Pick a value, then pick the kind of test data it is. Watch the two values that both get refused.

Watch out: 66 gets refused too, and that's right: slightly outside the edge means invalid. But it was picked to sit just past the edge, so its job is testing the boundary. Sort it as boundary data.

What do you really think?

Kai's test of the age check

Kai is testing the 18 to 65 age check. He types -5 and the screen shows: "Error: age must be 18 to 65".

Which idea is closest to what you think right now?
How sure are you?

Check the plan

One expected result is wrong

Here's Mia's test plan for the age check, which should accept ages from 18 to 65. Each line gives the test number, what it tests, the test data and the expected result. Which line has the wrong expected result?

Mia's test plan — which line goes wrong?

Your turn to write

Explain erroneous test data

Explain what is meant by erroneous test data and why it should be used when testing a program. [3 marks]

0 words · your answer stays on this page and is not sent anywhere.

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

1Use a range of test data: normal, boundary and erroneous (invalid).
2Erroneous data should not be accepted, because accepting it would cause an error.
3Predict every outcome first. For erroneous data the expected result is an error message.
4A test passes when actual matches expected. An unsuccessful test gets its fix recorded.

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?
To find and fix errors before users experience problems, and to make sure the program works as expected with different inputs.
Which three kinds of test data should a thorough test use?
Normal, boundary and invalid (erroneous) data.
What is normal test data?
Valid data the program should accept: the normal data you'd expect to be entered.
What is boundary test data?
Values on the edge of being valid. Values on or just within the boundary should be valid; values slightly outside it should be invalid.
What is erroneous (invalid) test data?
Data that should not be accepted by the program, because accepting it would cause an error.
A test checks that a user can't enter a value outside the allowed range. What is the expected result?
An error message is displayed.
When does a test pass?
When the actual output matches the expected result, even if that output is an error message.
An erroneous-data test ends with the data being accepted. What does that tell you?
The test failed: the program accepted data it should have refused, so it needs fixing and the fix should be recorded.
What does a good test plan include?
Clear tests with predicted outcomes, using a range of test data.
Why isn't a test plan made only of data that breaks the program good enough?
It never checks the program accepts the data it should. A plan needs normal, boundary and erroneous data.
Which four things does a test table specify for each test?
A unique identifier, a description of the test, the test data, and a description of the expected result.
What gets filled in on a test table as the testing is done?
The actual output and, if the test was unsuccessful, how it was fixed.

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 posted

More OCR GCSE Computer Science topics

See the full OCR Computer Science curriculum →

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.