Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Test data and test plans

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

50 minutes

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

WordWhat it meansExample
Test dataThe values you give to a program to test it.
Valid dataData the program should accept: the right kind and inside the limits.55 for a mark of 0 to 100
Invalid dataThe right kind of data, but outside the limits. The program should reject it.150
Boundary dataValues on the edges of the limits, and the first values just outside them.0, 100, -1, 101
Erroneous dataThe wrong kind of data. The program should reject it."abc"
Test planA table that lists each test, its data and its expected result.
Expected resultWhat should happen, decided before the test.
Actual resultWhat really happened when you ran the test.

The cells students fill in are left blank in this preview.

Four kinds of test data

KindExample for a mark from 0 to 100Expected result
Valid55Accepted
Invalid150Rejected: it is outside the limits
Boundary0, 100, and the values just outside: -1 and 101Accepted on the edge. Rejected just outside
Erroneous"abc" or nothing at allRejected: 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

Code: python
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

TestPurposeTest dataExpected resultActual result
1Valid data in the middle is accepted55AcceptedFill in when you run it
2The lowest valid mark is accepted0AcceptedFill in when you run it
3The highest valid mark is accepted100AcceptedFill in when you run it
4A mark just above the top is rejected101RejectedFill in when you run it
5A mark just below the bottom is rejected-1RejectedFill in when you run it
6Text instead of a number is rejectedabcRejectedFill 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 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

The lesson goes on

5 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.