It works, for you
Your booking code works. You typed 10 and it booked the hour.
Now a tester types "abc". Then 9. Then 21. Then nothing at all. Your code stops with an error.
You are the person who knows the code, so you try the easy things. A good tester tries the things that break it.
Key words
| Word | What it means | Example |
|---|---|---|
| Test plan | A table of tests written before you run them. | hour 21: expect refused |
| Test data | The values you use in a test. | 10, 21, "abc" |
| Valid data | A value the program should accept. | 14 |
| Invalid data | The right kind of value, but not allowed. The program should refuse it. | 5 |
| Extreme data | A value at the very edge of the allowed range: the first or the last one. | 9 and 20 are valid. 8 and 21 are invalid. |
| Erroneous data | The wrong kind of value. The program should refuse it. | the word "abc" for an hour |
| Expected result | What should happen, written before the test. | Refused |
| Actual result | What really happened. | Booked |
| Evidence | Proof that you ran the test and what happened. | a screenshot |
The cells students fill in are left blank in this preview.
A test plan for the hour check
| No. | Purpose | Data | Type | Expected | Actual | Action |
|---|---|---|---|---|---|---|
| 1 | Accept a sensible hour | 14 | Valid | Booked | ||
| 2 | Accept the first hour | 9 | Valid extreme | Booked | ||
| 3 | Accept the last hour | 20 | Valid extreme | Booked | ||
| 4 | Refuse just too early | 8 | Invalid extreme | Refused | Booked (wrong) | Change the check to start at 9, then run again |
| 5 | Refuse just too late | 21 | Invalid extreme | Refused | ||
| 6 | Refuse a very wrong hour | 5 | Invalid | Refused | ||
| 7 | Refuse words | abc | Erroneous | Refused | ||
| 8 | Refuse nothing typed | (empty) | Erroneous | Refused |
The cells students fill in are left blank in this preview.
Where the full table is needed
data-callouts.note.label
Task 2 asks for tests with proof: the purpose, the data, what you expect, what happened, and what you do next. Task 4a says a formal test document is not needed there. You must still test, so your product works. Practise the full table here.
Write the expected result first
data-callouts.warning.label
Write what should happen before you run the test. If you write it after, you may write what happened instead. Then every test passes, and the plan shows nothing.
Try it: a test is a small program
def valid_hour(text):
if text.isdigit():
hour = int(text)
if hour >= 9 and hour <= 20:
return hour
return None
def check(number, data, expected):
actual = valid_hour(data)
result = "FAIL"
if actual == expected:
result = "PASS"
print(number, data, "expected", expected, "got", actual, result)
check(1, "14", 14)
check(2, "9", 9)
check(3, "21", None)
check(4, "abc", None)
# isdigit() checks the text is only digits.
# >= means "is more than or equal to". <= means "is less than or equal to".
# Add a test for "8". Run it.
Quick check: test plans
Have a go
Quick check: test plans
5 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.