DEV Community

Leon Pennings
Leon Pennings

Posted on • Originally published at blog.leonpennings.com

The TDD Trap: How Test-First Becomes Bad Design Forever in Most Teams

1. Introduction: The Myth of Emergent Design

Test-Driven Development (TDD) promises a simple, seductive idea:

If you write tests first, good design will “emerge” naturally.

For two decades, this has been repeated across conferences, blogs, and books.

It sounds so logical: specifications become tests, tests become documentation, and architecture improves because you only build what’s required.

But the promise hides a structural flaw that quietly ruins codebases every day:

TDD forces design decisions long before the problem is understood.

Instead of guiding us toward good architecture, it often hardens misunderstanding into the foundation of a system. And by the time real complexity appears, the codebase is already littered with brittle tests defending a design that no longer fits the domain.

In other words:

Most teams using TDD end up preserving the wrong design — forever.


2. The Three Assumptions TDD Relies On — And Why They Fail in Reality

TDD depends on three background assumptions that rarely hold in real-world projects.

Assumption 1 — We know all relevant behavior when we write Story #1

In practice:

  • The first story exposes maybe 10–25% of real use cases.

  • The domain is still fuzzy.

  • Stakeholders don’t yet know what they really want.

  • Edge cases appear only after multiple iterations.

And most importantly:

  • True constraints never surface until deeper stories arrive.

This means the first tests encode behavior that is, at best, partial — and often simply wrong.

Assumption 2 — Behavior-first automatically leads to good structure

This is the philosophical core of TDD:

“Design emerges from tests.”

But what actually emerges is:

  • structure optimized for the first features,

  • procedural workflows disguised as architecture,

  • classes shaped by testability rather than by domain meaning,

  • boundaries that reflect user-story order, not domain reality.

TDD encourages what Kent Beck calls “the simplest thing that could possibly work.”

The problem?

The simplest thing is almost never the right thing when the domain is not yet understood.

Assumption 3 — Tests provide a stable foundation for evolution

TDD assumes tests behave like a safety net.

But early tests typically:

  • encode misunderstandings,

  • lock in accidental complexity,

  • constrain future refactoring,

  • break the moment domain insight changes the model.

So instead of enabling refactoring, they discourage it.

The foundation cracks the moment reality diverges from initial assumptions — which it always does.


3. The Reality Gap: Why Early Tests Become Design Handcuffs

The First Implementation Is Guaranteed Wrong

If your initial understanding covers only ~20% of actual scenarios, then your initial tests encode only that 20%.

This has two consequences:

  1. Your initial implementation is necessarily incorrect.

  2. Your test suite enforces that incorrect design with mechanical precision.

Developers soon face a dilemma:

  • Preserve the wrong design to keep the tests green

    or

  • Break the tests (often hundreds of them) to fix the model.

Teams almost always choose the first option.

Behavior Becomes a Straightjacket

Because TDD ties structure directly to behavior, every new insight becomes expensive:

  • New domain invariants contradict earlier tests

  • Structural refactors break dozens of test fixtures

  • Changes require rewriting test doubles, mocks, scaffolding

This makes structural correction harder over time, not easier.

The system becomes “correct according to outdated tests,” instead of “correct according to the real domain.”


4. How TDD Encourages Design Optimized for Testability, Not Quality

TDD tries to force design from the outside-in.

But what it typically produces is:

  • tiny methods created only to isolate dependencies

  • overly granular classes driven by the desire to mock everything

  • procedural workflows because domain models are slow to emerge

  • interfaces created only to facilitate mocking

  • over-abstracted layers because TDD discourages cohesive aggregates

This results in systems that look clean in isolation, but collapse under the weight of real complexity.

As a result:

The architecture reflects the order of stories, not the structure of the domain.

That is the core flaw.


5. What Real-World Experience Shows (Across Many Teams)

Across industries — finance, government, logistics, compliance — the pattern is consistent:

  • Teams begin with enthusiasm for TDD

  • Early progress feels great

  • Test suites grow quickly

  • Then domain complexity appears

  • And refactoring becomes painful

  • And tests turn into liabilities

  • And the architecture fossilizes

Teams rarely admit this publicly, but privately the story is common:

The tests start driving the design, instead of the domain.

It’s not that tests are bad.

It’s that tests written before understanding create enormous inertia.


6. The Critical Variable: Team Maturity

Whether TDD helps or harms a team correlates strongly with team maturity.

Low-to-mid maturity teams (most teams)

  • still learning the domain

  • still learning modeling

  • still forming architectural habits

  • still discovering edge cases

  • have high turnover or low domain continuity

For them, TDD amplifies instability:

  • They lock misunderstandings into the code

  • Refactoring becomes scary

  • Tests break constantly

  • Stress levels rise

  • Architecture emerges accidentally

  • “Green test = good design” becomes a substitute for thinking

High maturity engineering teams (rare)

Some highly experienced teams can use TDD as a consistency tool.

Not as a design method, but as a regression net.

The difference is profound:

  • They model before they test

  • They refactor aggressively

  • They throw away early tests

  • They don’t treat TDD dogmatically

  • They evolve tests along with understanding

  • They prioritize the domain, not the test suite

TDD “works” for mature teams precisely because they don’t follow TDD as originally prescribed.


7. So Should You Use TDD? My Answer: Almost Never as a Design Philosophy

Tests are good.

Automation is good.

Confidence is good.

But using tests as the engine of design is:

  • risky

  • expensive

  • rigid

  • overly optimistic

  • and counterproductive to long-lived domain models

In complex systems, design must come from understanding, not from initial behavior guesses.

Use tests to lock in insights once you actually understand the domain.

Not before.

That is the sustainable path.


8. What To Do Instead: A Domain-First Approach

If not TDD-first, then what?

1. Start with modeling, not tests

Sketch domain concepts.

Identify invariants.

Find aggregates.

Understand constraints.

Tests should validate these insights — not substitute for them.

2. Implement core domain logic directly

Don’t fragment it for testability.

Keep it expressive and cohesive.

3. Add tests once the model stabilizes

Now automation works with the domain, not against it.

4. Use tests as regression, not prophecy

Tests should confirm correctness — not predict future structure.


9. Conclusion: TDD Is Not Evil — Just Misapplied by Most Teams

TDD is not a bad idea in theory.

It’s just the wrong tool for the wrong stage of development.

It works beautifully when:

  • the domain is trivial,

  • the problem is well known,

  • or the team is extremely mature.

But for most real-world, evolving domains, TDD creates structural debt disguised as good engineering.

The truth is simple:

If you don’t fully understand the domain yet, TDD will lock misunderstandings into your architecture.

Test-first becomes mistake-first.

And mistakes, once encoded in hundreds of green tests, have a way of staying forever.

Top comments (0)