Test-Driven Development
Test-Driven Development (TDD) is perhaps the most important Extreme Programming (XP) rule that we practice. We're so passionate about testing, we wrote an entire book on it, Testing Rails.
Business benefits of TDD:
- Deliver more value, faster
- Always ship working software
- Adapt to change quickly
Code benefits of TDD:
- Readable specs and code
- Clean public interfaces
- Decoupled modules
Process benefits of TDD:
- Regression safety net
- Fearless refactoring
- Team trust
At a high level, how to test is very simple:
- Write test first.
- Red-Green-Refactor cycle.
For more specifics, we recommend our Test-Driven Rails workshop. It goes into incredible detail about the TDD workflow specifically for Ruby on Rails developers.