A test with no notes
A tester finds a bug on Monday. A programmer fixes it on Tuesday. On Wednesday nobody remembers what the tester did, with which data, or what the right answer was.
A test plan is the answer. It is a table that says what to test, how, and what should happen.
Key words
| Word | What it means | Example |
|---|---|---|
| Test plan | A table of the tests: what to do and what should happen. | One row for each test |
| Purpose | What the test is for. | Check that a 16-year-old is accepted |
| Pre-requisite | What must be true before the test can start. | The user is logged in |
| Expected result | What should happen if the software is right. | The form accepts the age |
| Actual result | What really happened when you ran the test. | The form refused the age |
| Re-test | Running a failed test again after the fix. | Run test 3 again |
| Regression testing | Running old tests again to check a change broke nothing else. | Run all 12 tests again |
| Test data | The values you use in a test. | 16 |
The cells students fill in are left blank in this preview.
What each column holds, and when
| Column | What you write | When you fill it in |
|---|---|---|
| Test number | A number so you can find the test | Before |
| Purpose | What the test checks | Before |
| Pre-requisite | What must be true first | Before |
| Test data | The values you will use | Before |
| Expected result | What should happen | Before |
| Actual result | What did happen | After you run it |
| Pass or fail | Do expected and actual match? | After you run it |
| Changes made | What you fixed | After a fail |
| Re-test result | Pass or fail after the fix, plus the old tests | After the fix |
The cells students fill in are left blank in this preview.
Match each column to its meaning
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Worked example: a filled-in plan
| No | Purpose | Pre-requisite | Test data | Expected | Actual | Result | Change made | Re-test |
|---|---|---|---|---|---|---|---|---|
| 1 | A normal age is accepted | Form is open | 17 | Accepted | Accepted | Pass | None | Pass |
| 2 | Lowest valid age is accepted | Form is open | 16 | Accepted | Refused | Fail | Changed age > 16 (bigger than 16) to age >= 16 (16 or more) | Pass |
| 3 | Just below the range is refused | Form is open | 15 | Refused | Refused | Pass | None | Pass |
| 4 | Text is refused | Form is open | abc | Error message | Error message | Pass | None | Pass |
The cells students fill in are left blank in this preview.
Row 2 shows a re-test and regression
Note
Test 2 failed. The programmer made a change. Then the tester ran test 2 again, and also tests 1, 3 and 4. Running tests 1, 3 and 4 again is regression testing.
Test, fix and test again
flowchart TD
plan[Write the plan with expected results] --> run[Run the tests]
run --> record[Write the actual result]
record --> ok{Did it pass?}
ok -->|yes| done[Done]
ok -->|no| fix[Fix the code and write the change]
fix --> retest[Re-test, then regression test everything]
retest --> record
Check: filling in the plan
Have a go
Check: filling in the plan
4 questionsBug hunt: fix the ticket machine
The ticket machine code has four bugs. The test plan found them. Read the rules at the top of the starter, then fix the code. After each fix, press Run Tests again. All four tests must pass at the end. A fix that breaks a test you passed before is a regression: find and fix that too.
# A bus ticket machine. The plan says:
# Under 5: free (0). Age 5 to 15: child fare 1.0. Age 16 and over: adult fare 2.5.
# A student aged 16 or over pays 1.5. A child who is a student still pays 1.0.
# An age below 0 is a mistake: use raise ValueError(...) to stop with an error.
# The code below has FOUR bugs. The tests in the plan found them. Fix them.
def ticket_price(age, is_student=False):
if age <= 5:
return 0
if age < 15:
return 1.0
if is_student:
return 2.5
return 2.5
Make a free account to save your work, or press Start lab to work through the whole lesson.
Run all the old tests after a fix
Many people think a fix only touches the bug it fixes. A fix can break something else. A programmer fixes the free ticket rule. By mistake, the child fare changes too.
Nobody notices, because only the free ticket test was run again. So after every change, run all the old tests. The hidden tests in the bug hunt do this for you.
Write a test plan
A website needs a password of 8 to 20 characters. Write a test plan with 6 rows. Use these columns: number, purpose, pre-requisite, test data, expected result. Include normal, valid extreme, invalid extreme and erroneous data. Leave the actual result empty, because you have no program to run yet.
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