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: Why test each part before the whole

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

55 minutes

The report that was wrong somewhere

A weekly report says the average lateness is 0 minutes. Everyone knows that is wrong. But where is the fault?

It could be in the code that reads the file, the sum, the report page, or the file itself. With everything joined up, the search takes hours.

Key words

WordWhat it means
Componentone part of a solution that can be tested alone
Interfacethe place where two parts meet and pass data
Softwarethe programs and scripts
Hardwarethe physical machines, drives and recording devices
Resulting servicethe finished product the user gets, such as a report or dashboard
Faultsomething wrong in a part that makes the result wrong
Testrunning something with known input to see if the output is what you expect

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

By the end of this lesson

Note

I can give reasons for testing each part of a solution before joining them, for software, hardware, data, interfaces and the finished service.

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.

Five kinds of part to test

PartIn data workWhat to test alone
SoftwareA cleaning scriptIt fixes spaces and capitals as expected
HardwareThe server, drive or recording deviceIt is on, has space and records readings
DataThe file of readingsIt is complete and in the right format
InterfacesWhere the script reads the fileThe file and the script agree on columns and format
Resulting serviceThe final report or dashboardIt shows the right numbers to the user

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

Reasons to test the parts first

  1. Easier to find a fault. If one small part fails, you know where to look.
  2. Cheaper to fix. An early fault costs a few minutes. A late fault may mean redoing joined work.
  3. Faults do not hide each other. Two small faults can cancel out, or one can look like another.
  4. Safer. A tested part can be trusted when you build on it.

Try it: test one part alone

Code: python
def parse_numbers(text):
    numbers = []
    for piece in text.split(","):
        piece = piece.strip()
        if piece.isdigit():
            numbers.append(int(piece))
    return numbers

print(parse_numbers("3, 4, x, 5"))
print(parse_numbers(""))

# One part, tested alone. Add a case of your own.

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.