fter the e-Commerce SIG talk I started chatting with a fellow attendee. We talked about what was not covered by the presentation.
The discussion drifted to Test Driven Development and the benefits. To my mind there are so many benefits that it is hard to pick a winner.
If TDD is too extreme for you or you are faced with non-unit tested legacy code, do not let the ideal of test first prevent you from adding unit tests.
Some of benefits of unit testing are
A powerful benefit is a change of mindset.
The above list is in part a manifestation of the change in mindset and in part a cause of the change.
Can the readers think of any other benefits.
The discussion drifted to Test Driven Development and the benefits. To my mind there are so many benefits that it is hard to pick a winner.
If TDD is too extreme for you or you are faced with non-unit tested legacy code, do not let the ideal of test first prevent you from adding unit tests.
Some of benefits of unit testing are
- Provides a safety net that promotes confidence about making changes to code.
- Instills a appreciation of the need to break dependencies.
- Promotes good Object Oriented design
- (bad design is hard to test)
- Allows you to see your component from the outside.
- (This helps increase ease of use from a callers perspective)
- It helps you focus on what you are try achieve instead of how you are going achieve it
- There are times where some or all of what you need to achieve is already there in the code
- (if this is the case the test will pass without you doing anything.)
- (The number of times I have deleted large sections of legacy code because the sections did not do anything useful is depressing)
- It encourages you to stick to what is needed immediately instead of adding what might be needed later.
A powerful benefit is a change of mindset.
The above list is in part a manifestation of the change in mindset and in part a cause of the change.
Can the readers think of any other benefits.
1 comment:
I'm don't do test-driven development myself, but I love built-in tests. (Here's my article on automated unit testing.)
The amount of time saved by having a regression suite that is run every time I compile is incredible. Sure, it probably didn't save much time during the initial development, but the time saved during maintenence is huge!
Post a Comment