Test Driven Developer
You got a TEST for that?
Home
|
Syndication
|
Sign In
Thursday, August 06, 2009
When NOT to use TDD
Test driven development is a great practice. But, sometimes we definitely should NOT use it.
right. who's this guy and where's John??
Really, sometimes the practice of TDD isn't in the best interest of the business. TDD has pro's and con's.
Pro's
better quality code
actually does what the developer wanted it to do
can safely change/refactor without worrying if we broke it
Con's
test code costs time and money to write
test code is overhead, it has to be maintained in addition to the main line code
some test code can be complex and harder to understand than the code it tests
The reason we test software is to mitigate risk. The risks we mitigate can be many, but we ought to have business value in mitigating a risk before we write a test. Some projects are so small and temporary that it doesn't justify writing tests. The business isn't interested in mitigating too much risk from the small project or temporary utility that isn't already covered by the standard things programmers do to run their programs before they call them finished.
Unit Testing is a great way to document functionality and illustrate that it works as intended. But the time and effort spent on writing the tests must be of value to the business - in the form of risk mitigation. For shipping products and tools that decisions will be based on, yes it makes sense to test it all thoroughly. The risk of customer problems and complaints, or bad decisions based on erroneous data are too high to leave un-mitigated. So we need to test them well to mitigate the risk and give that value to the business. Other times we can say a risk is just mitigated by the fact that we are "willing to accept" the risk. Acceptable Risk is a term I have heard used in threat modeling - indicating that the risk is so small or the problem so unlikely that we recognize it, but live with the risk that it may someday occur.
Testing is overhead, so make sure that the testing done is appropriate. Make sure that there is recognized and enumerable risk that can be mitigated by each test. Make sure that all the tests (unit, integration, functional, etc.) are warranted for the software being tested. I don't recommend under-testing either.
In Agile, one of our fundamental tenets is that we always strive to deliver value to the customer. For me, I strive to deliver value with each and every line of code, both main-line and in tests. Test the right things, and only at the right time.
Thursday, August 06, 2009 9:11:13 PM (Pacific Standard Time, UTC-08:00)
Comments [1]
|
Friday, August 07, 2009 8:56:22 AM (Pacific Standard Time, UTC-08:00)
I'm afraid I'll have to respectfully disagree with you.
First, while risk mitigation is one of the reasons to write tests, it is not the only reason (and may not even be the primary reason). One bigger reason is to maintain the changeability of the codebase (i.e. minimize the cost code changes). The cons that you list are all offset by the reduced costs changes.
For one of the best explanations of this that I have ever seen, watch this Keynote address by Robert Martin -- the section from minute 21 through minute 37 is about TDD: http://railsconf.blip.tv/file/2089545/
I think these are the Cons, or the times you should consider not using TDD:
- A legacy codebase that has no tests
- A team (or team member) that is against TDD
In the first case, Michael Feathers book as some good advice on getting a legacy codebase under test, but there are substantial upfront costs, and the payoff is way down the road. So, this requires management backing.
TDD is an acquired skill. You get better at it over time. If you have one or more team members who are opposed, they can easily sabotage the TDD effort. In such a case I would seriously consider whether it is worth the risk (preferably you'd get rid of the trouble makers).
Curt Hibbs
Comments are closed.
© Copyright 2010, John E. Boal
Calendar
<
July 2010
>
Sun
Mon
Tue
Wed
Thu
Fri
Sat
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
Total Posts: 44
This Year: 4
This Month: 0
This Week: 0
Comments: 22
Archives
June, 2010 (1)
April, 2010 (1)
March, 2010 (1)
February, 2010 (1)
September, 2009 (1)
August, 2009 (1)
June, 2009 (1)
May, 2009 (1)
April, 2009 (1)
February, 2009 (1)
January, 2009 (2)
December, 2008 (2)
November, 2008 (2)
October, 2008 (2)
September, 2008 (4)
August, 2008 (3)
July, 2008 (5)
June, 2008 (4)
May, 2008 (1)
April, 2008 (2)
March, 2008 (4)
February, 2008 (2)
January, 2008 (1)
On this page
categories
ABN
Acceptance Criteria
ATDD
Automation
Bugs
C#
Continuous Integration
Mocks
MSTest
Python
Refactoring
Selenium
SQL
TDD
Testing
Tools
Unit Tests
Video
WatiN
Links
Home
Test Driven Development, Defined (Wikipedia)
Test Driven Design
Test-Driven.com - Agile development tools
NUnit
Book: Test-Driven Development in Microsoft .NET
CodeProject - Advanced Unit Testing: Unit Test Patterns
John Boal's Personal Blog
John Boal's Agile Development Blog
Blogroll
OPML
Lazy Coder
Scott Koon's Blog
#2782
Ade Miller's Tech Blog
Agile Development
Mitch Lacey's Agile Development Blog
Espresso Fueled Agile Development
Mike Puleio's Blog
Geek Noise
Noise de Peter Provost
Sneal's Blog
Shawn Neal's Blog
Search
About
© Copyright 2010, John E. Boal
Sign In