AI-Written Code and Tests: The Shared Blind Spots Trap

You ask your AI coding agent to implement a FastAPI endpoint, then ask it to write the unit tests. pytest turns green. pytest --cov reports 100% line coverage. The diff looks clean, the assertions are readable, and the PR is ready to merge. Three days later, a client sends a slightly malformed payload and your endpoint returns a 500 error or silently applies a negative discount. This is not a freak incident. With AI-written tests generated in the same session as the implementation, both artifacts share the exact same implicit assumptions. The tests do not prove that the code survives reality: they only prove that the code matches what the model had in mind when it wrote it. ...

November 28, 2026 · 5 min · Anthony
AI-Written Code and Tests: The Shared Blind Spots Trap

TDD: Red-Green-Refactor, Baby Steps, and the FIRST Principles

TDD draws two extreme reactions. The first: “I already write tests, so I do TDD.” The second: “writing tests first just reverses the effort without buying much.” Both miss what TDD really is. It is neither a coverage question nor a simple ordering trick. It is a design discipline that forces you to make an intention explicit before writing the code that satisfies it. This article opens a series on TDD. Before comparing the schools (Chicago, London, ATDD double loop, strict TDD), the shared trunk has to be laid down: the Red-Green-Refactor cycle, the practice of baby steps, and the FIRST properties that define a test that deserves the name. The next articles will build on this foundation to make the trade-offs tangible with concrete examples. ...

June 8, 2026 · 8 min · Anthony
TDD: Red-Green-Refactor, Baby Steps, and the FIRST Principles

ExitStack: many patch() calls without a pyramid of with

A test that has to isolate a function from its dependencies often ends up stacking patch() calls. Three dependencies, three nested with blocks. Five dependencies, a pyramid that pushes the useful code ten levels deep. The test becomes unreadable even though its intent is simple: verify a single behavior at a precise boundary. contextlib.ExitStack solves exactly this problem. It is a context manager that aggregates any number of others and closes them all cleanly on exit. Here is how I use it to keep a test focused on its boundary, with a concrete example on authentication. ...

May 28, 2026 · 7 min · Anthony
ExitStack: many patch() calls without a pyramid of with

Newsletter

Get new articles delivered straight to your inbox.