Unit tests for testers
A unit test checks one small piece of code, fast and alone. Testers read them to see what is already checked and what is not.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: checking each Lego brick. Before building a castle, you check each brick. Is it cracked? Does it click? A cracked brick is easy to swap before it sits in a tower. Once the tower stands, finding the bad brick is slow work.
Daily List is a to-do list app. Leo writes a small piece of code that decides if a task is overdue. A task due yesterday should say overdue. A task due today should not. Leo writes a short test for each case.
Each test checks one piece of code, fast and on its own. This is a unit test. Tom, the tester, does not write them, but he reads them. They tell him what Leo has already checked, so he can spend his time on what is left.
The picture has a limit. Bricks are simple, but code pieces depend on other pieces. Also, a perfect brick does not mean a perfect castle.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
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 Checking each small piece alone and fast, and reading the checks to find the gaps.
- Pick one brick
- Set up the check
- Click it
- See what is missing
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| A Lego brick | A single piece of code |
| Checking the brick | A unit test |
| The click test | An assertion |
| A spare brick standing in | A test double |
WHERE THIS PICTURE STOPS
- Bricks are simple. Code pieces depend on other pieces.
- A perfect brick does not make a perfect castle.
- A brick check is done by hand. A unit test runs by itself.
HOOK
One brick, alone, fast.
REMEMBER IT THIS WAY
A rule of thumb: if you see this, think that.
Usually read the unit tests before you test a feature. What they leave out is where your time should go.
| In the trick | What it stands for |
|---|---|
| Unit test | Checks one piece of code, fast and on its own |
| Left over | What Leo has not checked yet |
It misleads when pieces pass alone but fail together, so reading unit tests does not replace testing the whole.
TELL A FRIEND
Checking each brick before building. Read the checks to see what is not checked.
OFTEN MIXED UP WITH Five test levels: parts, systems and acceptance. The test levels lesson names the levels. This lesson looks closely at the smallest level and how testers read it.
PRACTISE AND KEEP
Sources for this topic — 9 sources
- Market practice
ISTQB Certified Tester Foundation Level Syllabus v4.0.1 ↗ — International Software Testing Qualifications Board · Section 2.2, test levels: component testing checks single components in isolation, often by developers with tool support (confirmed against the syllabus, read in full text from a mirror copy of the publisher PDF, v4.0.1, 15 September 2024)
v4.0.1 is dated 15 September 2024 and is a list of corrections to v4.0 (21 April 2023) that reworded six learning objectives — not a cosmetic reissue. 78 pages.
Two traps this entry exists to stop. v4.0.2 is the German edition (1 March 2025, 94 pages), so sorting by version number reaches the wrong document. And the widely-repeated per-chapter question allocation "8 / 5 / 4 / 11 / 9 / 3" is wrong: it is 8 / 6 / 4 / 11 / 9 / 2, derived from three official sample-exam answer keys and confirmed against the Exam Structure Tables.
The single most consequential detail for a question bank: white-box coverage — statement and branch — is K2 "Explain", not K3 "Apply" (FL-4.3.1, FL-4.3.2, FL-4.3.3), and MC/DC, path and condition coverage are declared out of scope in §4.3. A question asking a candidate to compute branch coverage is testing something this syllabus does not.
Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.
Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.
Read from two independent PDF-to-markdown conversions mirrored on raw.githubusercontent.com. They are treated as faithful because they were produced by unrelated parties with different tooling, agree on the full 64-item objective set including wording, and reproduce the same internal inconsistency present in the source PDF. Chapter 1 reads "testware that supports" where Appendix B reads "that support". A conversion artefact does not replicate across two toolchains.
The licence permits attributed non-commercial extracts and use as the basis for articles. Whether a site that sells a pass may rely on that is an owner's decision, not this entry's.
7 November 2026 review: actual publisher PDF 4.0.1, 15 September 2024, 78 pages, front matter/copyright and relevant numbered operative sections 0.5–0.10 and chapters 1–6 compared with CTFLpractice lessons. Earlier mirror/search descriptions are historical access records. TheK2 white-box objectives require explanation; the source does not justify a categorical ban on small numeric illustrations that support explanation. Later Exam Rules 1.2§4.1.4 usesK2 for keyword definitions, while syllabus§0.5 usesK1; keep dated scopes distinct. No copied questions or figure assets.
- Market practice
Test Double (Martin Fowler bliki) ↗ — Martin Fowler · A test double replaces a production object for testing; kinds are dummy, fake, stub, spy and mock (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 · Google advice: write tests around behaviours, not methods, and name tests for the behaviour (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
The Practical Test Pyramid (Martin Fowler site, by Ham Vocke) ↗ — Martin Fowler / Ham Vocke · Unit tests check single pieces in isolation and sit at the base of the pyramid (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
How to use temporary directories and files in tests (pytest documentation) ↗ — pytest · pytest docs: tmp_path gives each test function a unique temporary directory; older runs are removed. Search excerpt, page not opened. freeCodeCamp thread is the learner question. Other languages have equivalents; none claimed.
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.
- Market practice
Embrace FIRST principles for reliable unit tests (HowToDoInJava) ↗ — HowToDoInJava · FIRST stands for Fast, Isolated, Repeatable, Self-validating and Timely; sources disagree on whether Timely means written before the code or at the right time; another source adds a sixth letter (search excerpt, page not opened; practitioner page)
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.
- Market practice
ISTQB Certified Tester Advanced Level Agile Technical Tester Syllabus v1.1 (PDF) ↗ — International Software Testing Qualifications Board (ISTQB) · Section 2.1.1 (ATT-2.1.1-2 and ATT-2.1.1-3, K2): a unit test should be deterministic, atomic, isolated and fast; FIRST is another mnemonic, giving fast, isolated, repeatable, self-validating and thorough (mirror copy of the publisher PDF, ISTQB Advanced Level Agile Technical Tester syllabus v1.1, 9 December 2019, read in full text)
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.
- Simplified educational illustration
Payments Signal editorial teaching models — Payments Signal
What this simplifies: Daily List, its tests and the people are invented. Sources differ on what the T in FIRST means: a practitioner page says timely and the Agile Technical Tester syllabus says thorough.
Used wherever diagrams, scenarios, figures, or example values are didactic constructions rather than sourced facts; every such use carries a simplifications disclosure. All people, companies, banks, and list entries in examples are fictional.
- Market practice
pytest temporary directories and files ↗ — pytest · tmp_path and retention sections; real unique per-test Path. Stable docs opened 6 November 2026.
Publisher primary source opened and relevant sections read on 6 November 2026 for the Agile/DevOps domain analysis. Original explanations are used; no extensive source text is copied.
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.