今日已更新 412 条资讯 | 累计 19972 条内容
关于我们

标签:#tdd

找到 3 篇相关文章

AI 资讯

Tests Pass, Design Breaks: Why TDD Can't Hold the Line on Design Intent

There is a popular misconception that if you do TDD, your design also stays correct. That if the tests pass, quality is guaranteed. In AI-assisted development, this misconception is the kind that quietly accumulates — the more tests you have, the more invisible damage builds up underneath. All tests passed. The design was still broken. Here is what happened today. A function called safe_post.py had its signature changed. Two arguments — notify_sh and doctor_sh — were removed. The test suite passed in full. But the callers were still using the old signature. They were silently broken. Why did the tests pass? Because the test code itself was using the old signature. The tests had been written (by AI) at a time when the design intent was already misunderstood. The misunderstanding was baked into the tests from the start. Tests passing and the design being correct are two different things. "All tests pass" tells you only one thing: the implementation matches what the tests expect. Whether the tests express the right design intent is a separate question. TDD verifies "implementation against tests" — nothing more Let me restate the TDD definition. Red → Green → Refactor. Write a test. Write the implementation that passes the test. Refactor. In this loop, what the test verifies is whether the implementation meets the test's expectation. That is one verification — and only one. What TDD does not verify is whether the test itself correctly expresses the design intent. The structure looks like this: Design intent → Tests (← this link is not verified) ↓ Implementation (← this link is verified by tests) If the person writing the tests misunderstands the design intent, the tests will pass and the design will still be wrong. Machine learning engineer Hamel Husain calls this the "Gulf of Specification" — the gap between what you intended to measure and what your metric actually measures. Optimize hard against a flawed metric and you optimize hard in the wrong direction. The same d

2026-06-27 原文 →
AI 资讯

It's Time We All Eat some more Cucumber!

Everyone's writing specs for AI now. We hand the model a markdown file, tell it what we want, and hope it builds the right thing. It mostly works — until it doesn't. Markdown has quietly become the spec language. People reach for it as the DSL for their AI-driven workflows — headings, bullet lists, the odd table — and treat that loose structure as if it were a contract. The thing is, it isn't a DSL. It's markdown. It's prose formatting with no grammar to enforce, no structure you can execute, no shared vocabulary, and no way to tell whether the spec and the code still agree. You're leaning on a document format to do a job it was never built for, and you hit the limit the moment you want the spec to actually mean something a machine can check. Before you go down that road, I want to make a small, slightly absurd suggestion. Eat a cucumber. What I actually mean Gherkin is the plain-text language behind Cucumber , a tool that's been around for years in the behavior-driven development (BDD) world. It looks like this: Feature : User login Scenario : Successful login with valid credentials Given a registered user "ada@example.com" When she logs in with the correct password Then she should land on her dashboard And she should see a welcome message Scenario : Rejected login with wrong password Given a registered user "ada@example.com" When she logs in with an incorrect password Then she should see an "invalid credentials" error And she should remain on the login page That's it. Feature , Scenario , Given / When / Then . Structured enough that a machine can parse it, loose enough that a product manager can write it. The gap it bridges Most specs live at one of two extremes. On one end you have written specs : docs, tickets, markdown files. Readable by anyone, but inert. Nothing checks whether they're still true. They rot the moment the code moves on. On the other end you have tests : precise, executable, always honest — but written in code, illegible to half the people who a

2026-06-08 原文 →
AI 资讯

Testing Discipline: A Beginner's Guide

Image by upklyak on Magnific Run an application. Click a few buttons. If the terminal doesn't have errors, then everything is working. Right? What's the point of writing tests if all seems to be fine. Let's explore testing discipline and why it's a habit every developer should build early. What is Testing Discipline? Testing discipline is the habit of verifying that your code works. It's not something you do at the end of a project. It's something you build into your development process. The goal is simple. Catch bugs as early as possible. A bug found while writing code usually takes minutes to fix. The same bug found in production can take hours to investigate, reproduce, and resolve. The earlier you find problems, the less expensive they become. Different Types of Tests When people talk about testing, they're usually referring to three categories. The first is unit testing . A unit test checks a single piece of functionality, usually a function or method. These tests are fast and easy to write, making them the best place for beginners to start. Next are integration tests . These verify that different parts of your application work together correctly. For example, does your service communicate properly with the database? Finally, there are end-to-end tests . These simulate a real user interacting with the application from start to finish. They provide the most realistic results but are usually slower and more complex. As a beginner, I recommend that you should focus on unit tests first. Different Testing Approaches As you continue learning, you'll come across different testing methodologies. One of the most popular is Test-Driven Development , often called TDD. The idea is simple. Write the test first. Watch it fail. Write enough code to make it pass. Many developers like this approach because it forces them to think about requirements before writing implementation details. You may also hear about Behaviour-Driven Development , or BDD. This approach focuses on desc

2026-06-01 原文 →