03 — Testing and verification
Commandment III: verify, don’t declare. Tests are the net you run again and again; verification is observed proof that this change does what it should. Both are mandatory.
Rules
- Every Commit — A saved, labelled point in the project’s history — a confirmation of a specific batch of changes. Small, described commits make a history you can return to any working state from. more in the glossary → that changes behavior carries a test. New Endpoint — A single “address” in an API you send a request to for a specific thing (e.g. the list of orders). Apps talk through endpoints — one endpoint = one function you expose. more in the glossary → → route test; new threshold or fallback → threshold test; fixed bug → a test that reproduced it first. A behavior change without a test is an incomplete commit. TDD — Test-Driven Development: first you write a test (what you expect), then the code that satisfies it. The test stays in the project and guards that a change broke nothing — proof instead of “it probably works”. more in the glossary → (red → green → refactor) is the default mode.
- Show proof, don’t ask the user to check: HTTP code / redirect, a confirming HTML fragment, numbers
from the database (
integrity_check: ok), a screenshot for visual changes. - Smoke test — A quick “does it even work” test right after a deploy — checks the most important paths (e.g. login). Catches disasters in 30 seconds before a user sees them. A cheap way to sleep well after a deploy. more in the glossary → check the right page, not just
200— a marker proving the expected content rendered. Test auth from both sides: anonymous is bounced, logged-in sees the content. - After a Deploy — Releasing a new version of the app “live”, where real people use it. It’s the moment a change reaches real people — which is why it happens only on an explicit “deploy”. more in the glossary →, smoke the live server (via localhost — The address a computer (or server) uses to connect to itself. On a server it lets you check the new version “from inside” before users see it. more in the glossary → behind the Maintenance window — A short, planned period when users see a “work in progress” page while the database or configuration changes behind it. It guarantees the app never runs, even briefly, on half-changed data. more in the glossary → flag).
- Report honestly: failures with their output; skipped steps as skipped; a failure caused by data drift (stale Fixture — Prepared data or state a test runs against (e.g. a small database with a few records). A test is only repeatable if it always starts from the same point. more in the glossary →) named as such, with a follow-up — not hidden, not used as a blocker.
- Numbers come from the source, not from memory or docs:
SELECT COUNT(*)doesn’t lie. - A Guard — A test that enforces a project rule (e.g. “every module is in the AI_README”) and stops the commit when it’s broken. A rule without a guard is only a wish — a long session will break it in good faith. more in the glossary → is proven by the incident, not by the fixture. A check written after an outage is replayed
against that outage’s real data before it’s trusted — fixtures share the author’s blind spot (a
freshness check once passed nine green tests and missed its own outage:
>where>=was needed). Then freeze the boundary in a fixture, with a test on the boundary. - Test the contract, not the implementation; keep the suite fast and deterministic (isolate I/O, seed randomness, serialize tests that share a port/DB). CI (continuous integration) — Automation that builds the project and runs the tests by itself after every change to the repository. A bug shows up minutes after the commit, not a week later in production. more in the glossary → gates Merge — Combining the changes from one branch into another. A merge brings in every commit from the source branch — other people’s too — so first you check what exactly comes in. more in the glossary → and deploy.
- Web projects carry by default: per-page SEO — Making sure search engines understand a site and show it high in the results. A site nobody can find effectively doesn’t exist. more in the glossary → meta, Canonical — A tag that tells search engines which address is “the real one” for a piece of content. It prevents duplicates (e.g. the same product under several addresses) that split your Google ranking. more in the glossary → + hreflang — A tag that tells the search engine what language a page is in and where its versions in other languages are. Without it a multilingual site confuses Google — the language versions “fight” over the same phrase. more in the glossary →, JSON-LD — Structured data: a description of the page invisible to humans that the search engine reads (e.g. FAQ, author, breadcrumbs). Opens “rich snippets” in Google — richer results, higher CTR. more in the glossary →, colour contrast and keyboard navigation, language parity as a failing test, no dead internal links.
Anti-patterns
- 🚫 “Should work” as a conclusion.
- 🚫 One test run, “suite green” declared.
- 🚫 No smoke after deploy “because the tests passed”.
- 🚫 “It compiles” confused with “it works for the user”.
- 🚫 Weakening a test or guard to make it green.