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

Preview

More testing methods and automation

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

A quiet Tuesday and Black Friday

A shop website works well on a quiet Tuesday. On Black Friday 20,000 people arrive at once.

The site is slow. Then it stops. The tests on Tuesday never saw this. Different problems need different kinds of testing. In this lesson you meet six more.

Key words

WordWhat it means
Performance testChecks how fast the system is and how much it uses.
Load testChecks the system with the number of users you expect on a busy day.
Stress testPushes the system past its limit to see how and when it breaks.
Usability testReal people try the product. You watch how easy it is to use.
Regression testRuns the old tests again after a change, to check nothing broke.
Closed box testYou test inputs and outputs. You cannot see the code.
Open box testYou can see the code and choose tests that use every path.
AutomationLetting a computer run the tests for you.
MacroA recorded list of actions that a program can repeat.
ScriptA small program that runs a job, such as running tests.
FunctionA named piece of code that does a job.
Unit testA test of one small part on its own.
PrototypeA simple early model of a product, used to try out an idea.

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

Six more testing methods

MethodPurposeWhen it is used
PerformanceIs it fast enough, and does it use too much memory?When speed matters, and after big changes
UsabilityCan real people use it easily?On a prototype and on the finished product
RegressionDid a change break something that worked?After every change or fix
LoadDoes it cope with the expected number of users?Before a busy time, such as a sale
StressWhat happens when it is pushed past its limit?To find the breaking point and see how it fails
Closed box and open boxTest with no view of the code, or with the code in viewClosed: acceptance and system tests. Open: unit tests

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

Closed box and open box

In closed box testing you treat the program like a sealed box. You put data in and check what comes out. You do not care how it works inside.

In open box testing you can see the code. You choose tests so that every path is used: every if, every elif and every else.

Try it: cover every path

Code: python
def fare(age):
    if age < 5:
        return 0.0
    elif age < 16:
        return 1.0
    else:
        return 2.5

# This function has three paths, so an open box tester needs three tests.
assert fare(3) == 0.0
assert fare(10) == 1.0
assert fare(30) == 2.5
print("All three paths tested")

# Delete the last assert. Which path is now never tested?

Benefits and drawbacks

MethodBenefitDrawback
PerformanceFinds slow parts before users doNeeds a realistic machine and data
UsabilityShows real problems that developers missSlow and costly: needs real people
RegressionCatches broken old featuresThe set of tests grows and takes time to run
Load and stressFinds the limit before a busy dayNeeds special tools and a copy of the live system
Closed boxTests like a real user, and the code does not guide the testsSome paths in the code may never be tried
Open boxCan test every path in the codeThe tester needs to understand the code

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

Quick check: which method?

Have a go

Quick check: which method?

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.

Let the computer do the testing

Running the same tests by hand is slow and boring. People make mistakes when they are bored.

Automation lets a computer run tests again and again, the same way every time. It is very good for regression tests: run all the tests after each change, even at night.

The lesson goes on

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