The Best Unit Testing Resources: Beginner to Expert
Software development is a bit like religion. People tend pick a side, and there they stay; sometimes for life. Each sect has certain accepted beliefs, and to consider ideas outside these is heresy. Because of this, it's extremely tough to get a lot of developers in agreement about something. And when this does happen, you should sit up and take notice.
In the last few years, unit testing has emerged as one of the Good Ideas of our craft. Support for this has grown to as near to unanimous as you could ask for. The last idea that reached this level of consensus was source control in the mid 90s, something that has obviously stuck around. Unit testing very well may be one of the lasting ideas of this decade.
Below I've put together the best unit testing resources I could find. If you're new to the concept, start with the introductory section. Veterans will likely want to jump ahead to the advanced topics.
Enjoy.
Introductory topics:
If unit testing is a foreign concept to you, I recommend starting with Wikipedia's article on the subject. Once you've gotten your head around the general idea, it's good to get grounded in some good testing practices: Charles Miller has a great article discussing six rules for unit testing.
If you're ready to get started, check out this list of unit test frameworks for over fifty languages. Find one for your language and get cracking.
Now, one approach for unit testing that you should know about is called Test Driven Development, or TDD. For a great example of this methodology in action, see this tutorial in which the author builds a simple IRC bot using TDD.
The most common objection raised against unit testing is that writing tests takes too long. This is often the biggest hurdle to adoption for UT in the workplace. James Golick debunks the "we don't have time to write tests" argument here.
Advanced topics:
Not all unit tests were created equal. Ray Osherove has crafted a great piece on coverage and writing maintainable and readable tests. Check it out. Also good is a post from his personal blog on writing tests that last, and why test reviews might be better than code reviews.
If your test suites are taking too long to run, check out this set of five rules for speeding up your tests.
Those of you familiar with design patterns may be interested in Marc Clifton's article on unit testing patterns. Also excellent is JUnit Anti-patterns. Though written for JUnit, it provides excellent general advice for avoiding buggy or poorly-written tests.
Finally, Tim Ottinger's post testing will challenge your conventions is a great summary of some of the ways TDD should be affecting your designs.