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
| Word | What it means |
|---|---|
| Component | one part of a solution that can be tested alone |
| Interface | the place where two parts meet and pass data |
| Software | the programs and scripts |
| Hardware | the physical machines, drives and recording devices |
| Resulting service | the finished product the user gets, such as a report or dashboard |
| Fault | something wrong in a part that makes the result wrong |
| Test | running 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 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Five kinds of part to test
| Part | In data work | What to test alone |
|---|---|---|
| Software | A cleaning script | It fixes spaces and capitals as expected |
| Hardware | The server, drive or recording device | It is on, has space and records readings |
| Data | The file of readings | It is complete and in the right format |
| Interfaces | Where the script reads the file | The file and the script agree on columns and format |
| Resulting service | The final report or dashboard | It shows the right numbers to the user |
The cells students fill in are left blank in this preview.
Reasons to test the parts first
- Easier to find a fault. If one small part fails, you know where to look.
- Cheaper to fix. An early fault costs a few minutes. A late fault may mean redoing joined work.
- Faults do not hide each other. Two small faults can cancel out, or one can look like another.
- Safer. A tested part can be trusted when you build on it.
Try it: test one part alone
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 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.