Approval Testing vs TDD
Summary
The article explores Approval Testing, a technique widely used for characterization testing in legacy codebases, and its debated application in driving Test-Driven Development (TDD). One perspective suggests that while not "canon TDD" due to undefined upfront assertions, approval tests can facilitate a TDD-like feedback loop. This involves iterating on a single test, reviewing diffs, and approving changes for refactoring. Conversely, a dissenting view argues that approval tests, being solution-based and reflecting implementation output, do not provide the same design guidance as traditional TDD, where tests define expectations before implementation. This perspective acknowledges approval tests' value for characterization but questions their efficacy in driving design during exploratory development.
Key takeaway
For software engineers evaluating testing strategies, consider approval tests for robust characterization of existing legacy code behavior. If you're accustomed to TDD's rhythm, you might find approval tests offer a useful iterative feedback loop, even if they don't strictly adhere to classic TDD's design-first assertion definition. However, be aware that approval tests primarily validate solution output, potentially offering less design guidance during initial exploration compared to traditional TDD.
Key insights
The core debate is whether approval tests, despite their utility, truly align with TDD's design-first principles.
Principles
- Approval tests excel at characterization of legacy code.
- Classic TDD defines assertions upfront to drive design.
- Approval tests assert based on solution output.
Method
The proposed TDD-like process with approval tests involves arranging and acting, then reviewing diffs of the actual output, approving changes, and refactoring.
In practice
- Use approval tests for legacy code characterization.
- Explore approval tests for iterative TDD-like feedback.
Topics
- Approval Testing
- Test-Driven Development
- Characterization Testing
- Legacy Code
- Software Testing
- Software Design
Best for: Software Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Modern Software Engineering.