Saturday, October 19, 2013
Test Driven Development Background
What is Test Driven Development?
You write a test first before you write the code. You use the tests to drive the design.
It uses one of the XP concepts : Test-First programming to achieve another XP concepts : Emergent Design.
In Emergent Design you start delivering functionality that has business value and let the design emerge. You will deliver functionality A with unit tests and then build functionality B. Then refactor to reduce duplication due to A and B and let the design emerge.
Origins of Test Driven Development
Extreme Programming Explained - Embrace Change by Kent Beck
Refactoring by Martin Fowler
Why TDD ?
- It results in simple design and minimal code.
- Higher quality code due to less defects
- Lower cost to maintain
- Brings fun back to programming
When is TDD not applicable?
- Asynchronous Code
- Exploratory work such as Architectural spike
- Checking the structure of user interfaces such as HTML
- Testing usability of user interfaces
What makes TDD difficult
- Doing TDD without pair programming. TDD and pair programming are complementary.
- Existing code base with no tests