What would you type to break it?
A form asks for a year group from 7 to 13. You are asked to test it. What do you type?
A good tester does not type only 10. They try 7 and 13, then 6 and 14, then 99, then the word "ten", then nothing at all. Each choice has a name.
Key words
| Word | What it means |
|---|---|
| Test data | values chosen to test a solution, with an answer you expect |
| Valid data | ordinary data that should be accepted |
| Invalid data | data of the right kind but outside what is allowed, which should be rejected |
| Boundary data | values at the edges of what is allowed, and just beyond them |
| Erroneous data | data of the wrong kind or nonsense, which should be rejected |
| Expected result | what should happen for a test value, decided before running it |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can name the four kinds of test data, say why each is used, and create test data for a check.
Starter
Have a go
Starter
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Worked example: testing year group 7 to 13
| Kind | Test value | Expected result | Why it is used |
|---|---|---|---|
| Valid | 10 | Accepted | Checks normal use works |
| Boundary | 7 | Accepted | The lowest allowed value |
| Boundary | 13 | Accepted | The highest allowed value |
| Boundary | 6 | Rejected | Just below the lowest |
| Boundary | 14 | Rejected | Just above the highest |
| Invalid | 99 | Rejected | Right kind, far outside the range |
| Erroneous | ten | Rejected | Wrong kind of value |
| Erroneous | (nothing) | Rejected | Missing value |
The cells students fill in are left blank in this preview.
Always decide the expected result first
Write down what should happen before you run the test. If you decide afterwards, you may talk yourself into thinking a wrong answer is right.
A good set has at least one of each kind. Together they test normal use, the edges, and what happens when someone makes a mistake.
Try it: run the values through a check
def year_ok(year):
if not isinstance(year, int):
return False
return year >= 7 and year <= 13
for value in [10, 7, 13, 6, 14, 99, "ten", ""]:
print(repr(value), "accepted:", year_ok(value))
# The expected results are in the table above. Do they match?
Check
Have a go
Check
4 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.