When designing or implementing a feature, we want to know that we are doing it properly. Once the feature is implemented, we want to ensure that it keeps working.
As part of our Continuous Integration practices, we are pushing for Test Driven Development, where unit tests are written BEFORE a new feature. It falls in line with the construction proverb: "measure twice, cut once".
By writing the test first:
- Ensures the code is loosely coupled
- Your code evolves in small steps
- You get automated regression testing
- You get living documentation as to how the system works
- etc.
- Start with your test first, to ensure that the test fails
- Implement the feature that makes the test pass
- Avoid fragile tests and tight coupling
@delivery @qa
- Magic tricks of unit testing Ruby, but excellent concepts