Class 9 · Computing and AI literacy
Test a form with unusual inputs
A sports-club form allows ages 5 to 18. If you test it only with age 10, what bugs might you miss?
What you will learn: Design normal, boundary and invalid test cases for a form.
Small test at the end: scroll down to the end of this page for five short questions that check what you have learnt. Tap an answer, then press Check answer. Go to the questions ↓
Jump to: Check yourself · For grown-ups · For teachers
Safety first
Made-up forms only. Never test real websites.
Keep it safe:
- Use made-up forms and data only. Do not test real websites or forms that you do not own.
You will need
- Paper and pencil
- A made-up formDraw a form with one box and its rule.
Time: About 40 minutes.
The story
Dhruv has built a sign-up form for the sports club: ages 5 to 18 only. He tests it with age 10, and it works. "Finished!" he says. Tara types 18, and the form turns her away. What other unusual inputs should he have tried?
The idea
Normal values are ordinary inputs, such as 10. Boundary values are right at the limits: 5 and 18 (should be accepted) and 4 and 19 (should be rejected).
Many bugs hide at the limits. If a programmer wrote "less than 18" instead of "18 or less", age 18 would be wrongly rejected. Only a boundary test finds it.
Invalid values are the wrong kind of input: words instead of numbers, or a blank box. A good form rejects them with a helpful message.
Write the expected result before you test. Then a test either matches it (pass) or shows a bug (fail).
Worked example
Testing the club form
- Normal: 10. Accepted. Pass.
- Boundaries: 5 accepted, pass. 18 rejected! Fail: the form used "less than 18".
- Just outside: 4 and 19 rejected. Pass.
- Invalid: "ten" rejected with "Please type your age in numbers". Blank rejected with "Please enter your age". Pass.
One normal test would have passed. The boundary test at 18 found the bug.
Try it
Write the rule.
For example: ages 5 to 18 allowed.
List test inputs.
One normal, the two boundaries, one just outside each, and two invalid ones.
Write expected results.
Accept, reject, or reject with a message.
Run the tests.
A friend plays the form, following its rule as written. Record what happens.
Mark pass or fail.
For each failure, write what the bug probably is.
What you make (paper or offline)
Your test-case table
At least seven test cases.
Expected and actual results.
Pass or fail, and a note on each bug found.
Make it on paper. Keep it with you. Nothing to upload.
Check yourself
Five questions about what this page teaches. Choose an answer and press Check answer, or open "See the answer and why". Nothing is saved or sent: your choices stay on this screen and disappear when you leave or reload the page.
See the answer and why
- A. 10 and 12 Not this one. Those are normal values in the middle.
- B. 0 and 100 Not this one. They are outside, but not right next to the limits.
- C. 5 and 18 Not this one. Those are the limits themselves, inside the allowed range.
- D. 4 and 19 Correct. Each is one step beyond a limit and should be rejected.
See the answer and why
- A. Accept it Correct. 18 is inside the allowed range.
- B. Reject it Not this one. "5 to 18" includes 18.
- C. Change it to 17 Not this one. A form should not change what the user typed.
- D. Ask for a parent's age instead Not this one. That is not part of the rule.
See the answer and why
- A. To make the test table longer Not this one. Each boundary test has a purpose.
- B. Bugs often hide exactly at the limits Correct. A mistake such as "less than 18" instead of "18 or less" shows up only at the edge, never with 10.
- C. Because 4 and 19 are the most common ages of members Not this one. They are chosen for being at the edges, not for being common.
- D. Because 10 is an invalid value Not this one. 10 is a normal, valid value.
See the answer and why
- A. Accept it and fill in 10 Not this one. The form should not invent an age.
- B. Reject it with "Please enter your age" Correct. It stops the error and says how to fix it.
- C. Accept it as age 0 Not this one. Blank is not the same as 0, and 0 is outside the limits.
- D. Close the form with no message Not this one. The user would not know what went wrong.
See the answer and why
- A. The form works as it should Not this one. The rule says reject 19, so it does not.
- B. A bug: 19 is above the limit Correct. The expected result was reject, so the test failed.
- C. The test is wrong, because 19 is a normal value Not this one. 19 is just outside the limit, not normal.
- D. Nothing, because 19 is close to 18 Not this one. Close is not allowed. The rule is 5 to 18.
Think back
Which test found the most interesting result?
Why write the expected result before you test?
Investigate further
- Write test cases for a password rule: 8 to 20 characters.
- Test a made-up "marks out of 100" box. What are its boundaries?
For grown-upsTap a heading to open it. The safety notes are at the top of the page.
Before you start
- Play the role of the form, following its rule exactly, even a buggy one, so the student can find the bug.
Questions that help
- "What happens right at the edge?"
- "What would a careless user type?"
What's really going on
Boundary-value and invalid-input testing are standard software testing techniques: many real bugs sit at the limits.
Testing only real websites you own, or with permission, is an important rule.
Other ways to do it
- Test a made-up lift rule: "maximum 8 people".
For teachersLearning aims, classroom ideas and what to look for.
Learning aims
- Design normal, boundary and invalid test cases.
- Use expected results to identify bugs.
Subject links
- Computing: testing and debugging.
- Mathematics: inequalities.
These links are general. They have not been checked against a specific board syllabus.
In the classroom
- One pupil secretly uses a buggy rule; the class designs tests to find it.
What to look for
- Tests both sides of each boundary.
- Writes expected results first.
