Test smells and maintainable checks
Spot the signs that an automated check will be hard to keep, and write checks that survive harmless change.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: kitchen hygiene. You smell the bin long before you see mould. A smell is a warning. It does not mean the food is ruined. It means: look now, before it gets worse.
Daily List is a to-do list app. Tom has a suite of automated checks. Some of them fail every time Leo renames a helper in the code. The users see no change at all. Nobody dares to touch these checks, because nobody can tell what they are for.
Those are smells in the test code. A is a sign that will be hard to read, trust or change later, even if it passes today.
The picture has limits. A food smell is the same for everyone. A test smell depends on the team and the moment, so it is a hint, not a verdict.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PLAIN WORDS · 1 in this section
- renames
- gives a new name
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Noticing early signs that will be hard to keep, and fixing them while the repair is still small.
- Notice the sign
- Ask what the user sees
- Make the small fix
- Keep cleaning in small steps
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The smell | A sign in the test code, such as copied steps |
| The mould | A suite nobody trusts or touches |
| Cleaning the fridge each week | Small, steady repairs |
| Eating the food | Running the check and seeing a pass |
WHERE THIS PICTURE STOPS
- A food smell is the same for everyone. A test smell depends on the team.
- A bad smell means throw it away. A test smell means look closer.
- Mould is easy to see. Smells in test code need a reader to notice.
HOOK
Smell it early.
REMEMBER IT THIS WAY
A sequence: the real steps, in order.
When feels wrong, ask in order: what smells, what does the user see, what is the small fix?
| In the trick | What it stands for |
|---|---|
| What smells | A sign in the test code, such as copied steps |
| What does the user see | The users see no change at all |
| The small fix | Repair while the repair is still small |
A smell is a hint, not a verdict, and it depends on the team and the moment.
TELL A FRIEND
A smell is an early warning that will go bad. Fix it while it is small.
OFTEN MIXED UP WITH Reading an automated check. The reading lesson shows how to follow one check. This lesson asks whether the check will be easy to keep.
PRACTISE AND KEEP
Sources for this topic — 6 sources
- Market practice
The Open Catalog of Test Smells ↗ — Open Catalog of Test Smells · Test smells are grouped as code smells, behaviour smells such as Fragile Test and Assertion Roulette, and project smells such as high test maintenance cost (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Mystery Guest (thoughtbot, after Meszaros's xUnit Test Patterns) ↗ — thoughtbot · Obscure Test is a test that is hard to understand by reading it, and Mystery Guest is one cause (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Unit Testing, chapter 12 of Software Engineering at Google ↗ — Google (Abseil) · Tests should exercise public behaviour, not implementation details; brittle tests fail on harmless change and take a growing share of a team's time (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Testing on the Toilet: Test Behaviors, Not Methods (Google Testing Blog, 2014) ↗ — Google · Test behaviours, not methods (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
What to look for in a code review (Google Engineering Practices) ↗ — Google · A reviewer checks design, functionality, complexity, tests, naming and comments (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Certified Tester Advanced Level Test Automation Engineering sample exam answers, version 2.2 (copy hosted by the American Software Testing Qualifications Board) ↗ — American Software Testing Qualifications Board · The answer key shows a section 4.3 objective on keeping automation code maintainable (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. Version: Version 2.2.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.