Unit Testing Pros And Cons
"Unit Testing is teh suck" - this post, and some of the comments to it, represent just about every conceivable FUD (fear, Uncertainty, Doubt) about Unit Testing and Test Driven development I've heard, so I'd urge you to go and read that post and especially its comments.
Why?
If you're not sure about Unit Testing, you'll certainly be familiar with some of the fears and doubts mentioned there, which will make you feel better about yourself, but still when you read the comments you'll get a sense that things are not as black and white as they appear to be - Unit Tests could be good for you, or at least they seem to be working just fine on *some* projects out there.
If you're pro Unit Testing, have tried it and have failed, you might find yourself agreeing with some of the stuff mentioned there as some of the core reasons why you failed to do Unit Testing with your Project, but it does not have to be this way.
My Upcoming book deals a lot with ways and techniques to make sure that whatever practical problems you face when writing unit tests (Maintaining Unit Tests is very time consuming, Some part of the code are not testable, Not trusting your Unit Tests etc..) are solved to a degree that your Unit Tests "do much more good and much less harm" -- they're worth writing.
Many projects I've seen tried to do unit tests and failed for many reasons:
- Tests were written poorly and so would fail or pass intermittently
- Changing Tests after changing the API took way too much time so people simply gave up on them
- Writing the tests was too hard for the API
- Tests took too long to run or required massive amounts of setup to run, so no one ran them and all the bugs were found at once, or bugs could not be detected correctly - it was "debugging night" all over again.
- Management did not approve of taking lots of time to write tests in a Test Driven Manner (political decision, always)
- many other reasons.
Most of the problems mentioned here can be solved by implementing some technique to Unit Testing, some of which I've described in this MSDN article, and you can find many others in this series of blog posts in my blog "Testing Guidelines" Category.
"The Art Of Unit Testing" will deal with many of these techniques head on and in deep fasion and not only explain what can be done, but why it's important.