Techniques

Test-Driven Development

Red, green, refactor—sometimes

Trial
Assessment
Trial
Ring
status
Techniques
Quadrant
category
2025-11
Updated
last eval
1
Related
technologies

Why Trial (Not Adopt)

TDD is powerful but dogmatic application hurts productivity. I use TDD selectively, not religiously.

When TDD Shines

  1. Complex algorithms - Writing tests first clarifies the spec
  2. Bug fixes - Write a failing test, then fix
  3. API contracts - Tests document expected behavior
  4. Refactoring - Tests provide safety net
  5. Pair programming - One writes tests, one implements

When TDD Hurts

  1. Exploratory coding - Don’t know what I’m building yet
  2. UI work - Tests are brittle, iteration is fast
  3. Integration code - Mocking external services is tedious
  4. Prototypes - Throw-away code doesn’t need tests

My Actual Practice

Services - Usually TDD. Business logic is testable and stable.

# Write test first
test "processes valid order" do
  result = Orders::Process.new(order: valid_order).call
  assert result.success?
end

# Then implement

Controllers - Test after. I want to see the feature work first.

Views - Minimal testing. System tests catch integration issues.

AI-generated code - Never TDD. Let Claude generate, then write tests to verify.

The Honest Truth

Pure TDD advocates say “never write code without a failing test first.”

In practice, I write tests first maybe 30% of the time. The other 70%:

  • Spike first, test after
  • Let the feature stabilize, then lock it down
  • AI generates code, I verify with tests

The goal is confidence in your code, not adherence to a process.

Test Coverage Goals

I aim for:

  • 90%+ on services and business logic
  • 70%+ on controllers
  • System tests for critical paths
  • Skip testing obvious framework behavior

High coverage everywhere is a vanity metric. High coverage on risky code is engineering.

Quick Facts

My Verdict
Valuable technique, not a religion
Use Cases
Complex business logic API contracts Refactoring safety Bug fixes

Stay updated on my tech choices

Get insights on tools, frameworks, and technologies I'm evaluating for my builds.

Subscribe Free