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

Preview

AC 2.9: Choosing and creating test data

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

60 minutes

What would you type to break it?

A form asks for a year group from 7 to 13. You are asked to test it. What do you type?

A good tester does not type only 10. They try 7 and 13, then 6 and 14, then 99, then the word "ten", then nothing at all. Each choice has a name.

Key words

WordWhat it means
Test datavalues chosen to test a solution, with an answer you expect
Valid dataordinary data that should be accepted
Invalid datadata of the right kind but outside what is allowed, which should be rejected
Boundary datavalues at the edges of what is allowed, and just beyond them
Erroneous datadata of the wrong kind or nonsense, which should be rejected
Expected resultwhat should happen for a test value, decided before running it

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

By the end of this lesson

Note

I can name the four kinds of test data, say why each is used, and create test data for a check.

Starter

Have a go

Starter

3 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.

Worked example: testing year group 7 to 13

KindTest valueExpected resultWhy it is used
Valid10AcceptedChecks normal use works
Boundary7AcceptedThe lowest allowed value
Boundary13AcceptedThe highest allowed value
Boundary6RejectedJust below the lowest
Boundary14RejectedJust above the highest
Invalid99RejectedRight kind, far outside the range
ErroneoustenRejectedWrong kind of value
Erroneous(nothing)RejectedMissing value

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

Always decide the expected result first

Write down what should happen before you run the test. If you decide afterwards, you may talk yourself into thinking a wrong answer is right.

A good set has at least one of each kind. Together they test normal use, the edges, and what happens when someone makes a mistake.

Try it: run the values through a check

Code: python
def year_ok(year):
    if not isinstance(year, int):
        return False
    return year >= 7 and year <= 13

for value in [10, 7, 13, 6, 14, 99, "ten", ""]:
    print(repr(value), "accepted:", year_ok(value))

# The expected results are in the table above. Do they match?

Check

Have a go

Check

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

4 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.