By Roy Osherove
320 pages
http://www.amazon.com/Art-Unit-Testing-Examples-NET/dp/1933988274
So, I ordered this book along with a few others when my team was about to start writing unit tests. Of all the books I ordered, this one was the most packed with realistic, hands-on guidance on how to organize your tests, and wide-ranging best practices and test patterns for how to write tests that are easy to maintain.
Roy Osherove has a lot of experience helping companies with “the art” of unit testing. He believes the key to successful unit testing rests on three pillars: maintainability, readability, and trustworthiness. He explains in the book what those things actually look like in real-world examples and why you might not be getting everything you could be out of your tests if you overlook one of those.
Roy also includes a fairly detailed comparison of the latest tools and frameworks you have to choose from. This section alone could save a ton of research time by getting a fairly unbiased, expert’s view of the pros and cons for these types of tools and frameworks:
- Test Frameworks: NUnit, MSTest, MbUnit, Gallio, xUnit, Pex
- Isolation Frameworks: Moq, Rhino Mocks, Typemock Isolator, NMock, NUnit.Mocks
- IoC Containers: StructureMap, Unity, Castle Windsor, Autofac, Common Service Locator (CSL), Spring.NET, Managed Extensibility Framework (MEF), Ninject
- Web Testing: Ivonna, VS Team System Web Test, NUnitAsp, Watir, WatiN, Selenium
- UI Testing: NUnitForms, Project White, Team System UI Tests
- Thread-Related Testing: Typemock Racer, Microsoft CHESS
- Acceptance Testing: FitNesse, StoryTeller
This book was a short 320 pages, but there is a ton of practical and applicable tips jammed between the covers. But, I have to mention that this book isn’t as polished as you would probably expect with most published works. It isn’t anything major, but just a few things in the text or code samples that should have been caught by testers or an editor. These issues don’t really take away from the content, but it just wasn’t up to the standard I expect when buying a published work. (And that is possibly the worst cover I have ever seen ... yes, I get the reference to "The Art of War").
If you are remotely interested in this topic, you should listen to a recent podcast Roy did with Scott Hanselman on “The Art of Unit Testing.” Although the podcast is kind of like a cliff-notes version of the book … it isn’t a replacement. If you find the podcast remotely helpful, order the book.