Testing a lift
A lift (an elevator in a building) has a sign: maximum 8 people. How would you test it?
Try 3 people. Try exactly 8. Try 9. Try 0. What about a chair, or a dog? Each of these is a different kind of data for a test. The values you use to test are called test data (the data you test with). Good testers choose it carefully.
Key words
| Word | What it means | Example |
|---|---|---|
| Test data | The values you give to a program to test it. | |
| Valid data | Data the program should accept: the right kind and inside the limits. | 55 for a mark of 0 to 100 |
| Invalid data | The right kind of data, but outside the limits. The program should reject it. | 150 |
| Boundary data | Values on the edges of the limits, and the first values just outside them. | 0, 100, -1, 101 |
| Erroneous data | The wrong kind of data. The program should reject it. | "abc" |
| Test plan | A table that lists each test, its data and its expected result. | |
| Expected result | What should happen, decided before the test. | |
| Actual result | What really happened when you ran the test. |
The cells students fill in are left blank in this preview.
Four kinds of test data
| Kind | Example for a mark from 0 to 100 | Expected result |
|---|---|---|
| Valid | 55 | Accepted |
| Invalid | 150 | Rejected: it is outside the limits |
| Boundary | 0, 100, and the values just outside: -1 and 101 | Accepted on the edge. Rejected just outside |
| Erroneous | "abc" or nothing at all | Rejected: it is not a whole number |
The cells students fill in are left blank in this preview.
Why edges matter
Many bugs are at the edges of the limits. A programmer writes age > 13 when they should write age >= 13. Test data of 5 or 15 never finds it. Only 13 does. (With age > 13, the value 13 is wrongly rejected.)
So always test the lowest and highest valid values, and the first value outside each one.
Try it: run the test data
def mark_ok(text):
return text.isdigit() and int(text) >= 0 and int(text) < 100
for data in ["55", "0", "100", "101", "abc"]:
print(data, mark_ok(data))
# One answer is wrong. Which data found the bug? What is the bug?
The test plan
A test plan is written before the testing starts. It says what you will test, why, with what data, and what should happen.
You fill in the last column during the test. If the actual result is not the expected result, the test fails and you have found a bug.
A test plan for a mark
| Test | Purpose | Test data | Expected result | Actual result |
|---|---|---|---|---|
| 1 | Valid data in the middle is accepted | 55 | Accepted | Fill in when you run it |
| 2 | The lowest valid mark is accepted | 0 | Accepted | Fill in when you run it |
| 3 | The highest valid mark is accepted | 100 | Accepted | Fill in when you run it |
| 4 | A mark just above the top is rejected | 101 | Rejected | Fill in when you run it |
| 5 | A mark just below the bottom is rejected | -1 | Rejected | Fill in when you run it |
| 6 | Text instead of a number is rejected | abc | Rejected | Fill in when you run it |
The cells students fill in are left blank in this preview.
Quick check: the plan
Have a go
Quick check: the plan
4 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.