AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Term 2 check-in

Week 21 · Review: Term 2 · 3 lessons
2

Test data and valid data

Computing 8: Topics 1.6–2.2, pp. 137–229
GoalChoose normal, boundary and invalid test data, find a boundary bug with a test plan, and explain what validation checks do and do not prove.
New words
boundary data · test data on the edge of what is allowed, and just outside ittest plan · a table of tests with the expected outcome worked out by hand before the program is runvalidation · an automatic check that data is reasonable (it cannot prove it is true)field list · a table that lists each field of a database with its data type and validation rule
Explanation

A test plan lists the test data, its type, the outcome you expect and the outcome you actually get. The expected outcome is worked out by hand first, from the rule, so you do not copy what the program says. Normal data is an everyday value that should work. Boundary data sits at the limits of the allowed values and one step beyond them. Invalid data should always be rejected. Validation is the same idea built into the program: a presence check makes sure something has been typed, a range check keeps a number between two limits, a length check counts characters and a format check controls the pattern, such as DD/MM/YYYY. Validation checks that data is reasonable, not that it is true. A pupil who is 11 can type 14 and pass a range check of 9 to 15.

NormalBoundaryInvalid
a typical valueon the edge and just outsideshould be rejected
Worked examples
TestType of dataTest dataExpected outcomeActual outcomePass/fail
1normal17Gold badgeGold badgepass
2normal8No badgeNo badgepass
3boundary15Gold badgeNo badgefail
4boundary14No badgeNo badgepass
5boundary20Gold badgeGold badgepass
6boundary21Invalid scoreInvalid scorepass
7invalid35Invalid scoreInvalid scorepass
A badge program: a score out of 20 earns a gold badge from 15 upwards, and any score outside 0 to 20 is invalid. A pupil first wrote score > 15 by mistake. The plan was worked out by hand first (the Expected outcome column), then run with the wrong version. Only the boundary test 15 fails, because the normal tests 17 and 8 pass both versions.
Name typedAge typedProgram prints
Ana12Saved
(nothing)12Name needed
Leo16Age not allowed
Leo9Saved
Leo8Age not allowed
Two validation checks in a registration program. The presence check makes sure the name is not empty. The range check lets only ages 9 to 15 through. Each row shows what the program prints.
Pupil nameClass yearBooks readStart dateResult
Mei81203/09/2025accepted
Omar10515/01/2026rejected: class year
(nothing)7001/10/2025rejected: name
Lina95107/11/2025rejected: books read
Tom8203/9/25rejected: date format
Five records checked against a field list. The rules are: the pupil name is not empty, the class year is 7 to 9, the books read are 0 to 50, and the start date has the format DD/MM/YYYY. A record must pass every rule. The last record fails the format check, because 3/9/25 is not written DD/MM/YYYY. Different formats in one field also make a search miss records.
Class activity

Rule-breaker game (no computer). Write a rule on a card, such as Cinema seats are numbered 1 to 60. One player writes six test values on small papers and shuffles them: two normal, two boundary, two invalid. The other player sorts them into three piles and explains each choice, then says what the program should do for each value. Swap roles with a new rule. Finally invent a wrong version of the rule (for example 1 to 59) and show which pile of tests would catch it. If you have a computer or tablet, an adult can help you run the badge program and compare it with the plan.

Practice
1
A kitchen timer accepts 1 to 90 minutes. Put these test values into normal, boundary and invalid: 45, 90, 91, 1, 0, 200.
2
A museum rule says children aged 5 and under enter free. This program uses age < 5. Which test finds the mistake? What should the code be, and what kind of error is it?
Python
1age = int(input("Age? "))
2if age < 5:
3    print("Free")
4else:
5    print("Pay")
3
Look at the field list. Which checks reject (a) Class year 10, (b) Books read 51, (c) a blank pupil name, (d) the date 5 June 2025? Name the type of check each time.
FieldData typeValidation rule
Pupil nametextpresence check: not empty
Class yearintegerrange check: 7 to 9
Books readintegerrange check: 0 to 50
Start datetextformat check: DD/MM/YYYY
4
A pupil aged 12 types 14, and the range check 9 to 15 accepts it. Does this mean the data is correct? Explain.