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.
Match the value to its test type
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
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
Note
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
Warning
Many people fill in the expected result after the test. Then they copy what happened, every test passes, and the plan shows nothing. Write what should happen first, from what the brief asks.
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.
Make a free account to save your work and track your progress.
Check: test plans and test data
Have a go
Check: test plans and test data
5 questionsStage 4a: write the hour check
This is stage 4a of the Hillside practice project. Write valid_hour. It takes what a person typed and gives back the hour as an integer if it is a whole number from 9 to 20. For anything else it gives back None. Think about empty text, words, decimals (like 10.5), numbers below zero and spaces. Press Run Tests to check your work.
def valid_hour(text):
# text is what a person typed, such as "10" or " 9 ".
# Give back the hour as an integer if it is a whole number from 9 to 20.
# Spaces at the start or end are fine.
# Give back None for anything else: empty text, words, decimals, 8, 21.
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
A screenshot for each test is proof
A test with no proof is only words. Keep evidence.
Take a screenshot of each result. Name the file with the test number: test-05-hour-21.png. Put the date and time in your log.
If a test fails, keep the screenshot of the failure too. Then show the fix and the second run.
Good and weak evidence
| Weak | Good |
|---|---|
| "I tested it and it worked" | A table with the data, the expected result, the actual result and a screenshot |
| One screenshot of one pass | A screenshot for each test number, including failures |
| No date | Date and time in the log |
| Fixed code with no note | The failing run, the change and the passing run |
The cells students fill in are left blank in this preview.
Stage 4a: your test plan
Write a test plan for your book function from the last lesson. Use a table with the columns: No., Purpose, Data, Type, Expected, Actual, Action. Write at least ten tests. Include valid, valid extreme, invalid, invalid extreme and erroneous data. Write the Purpose and Expected first. Then run each test and fill in Actual. Add a screenshot or a copy of the output for at least three of them. If a test fails, write what you changed in the Action column and run it again.
A teacher marks this in a college. Nothing you write here is kept: it goes when you leave the page.
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Final check
Have a go