Top positive review
2 people found this helpful
Good introduction to unit testing of .Net projects. Easy read.
on 9 April 2012
"The Art of Unit Testing" by Roy Osherove is a good, introductory book re. unit testing for those working with .Net, particularly for those using (or planning to use) NUnit and RhinoMocks.
It's an easy read, that goes through what makes a good unit test, how to write a simple unit test using NUnit, how to replace dependencies with manually created stubs, how to manually create mocks, then how to use a mocking framework (e.g. RhinoMocks) to dynamically creates stubs and mocks. There's useful advice on things like naming conventions, how to organise projects and folders, integrating into the build system, how to introduce unit testing into an organisation, and how to work with legacy code. There's also advice on OOD for testability, including interface driven development and use of inheritance in order to break dependencies or allow insertion of objects to allow unit testing to take place (this has been a serious mental block for some developers I have worked with in the past - not being able to recognise that, with a little re-factoring, code that they thought could only be tested using integration/system testing can have dependencies broken to allow unit testing to take place). Together with numerous links/references to other tools and materials, this is a great, easy to read, and fairly short, introduction. It's one of a short list of books that I think all .Net developers should read.
This is not, however, the complete guide to unit testing in the .Net world. For example, it touches on Inversion of Control containers (e.g. Castle Windsor) but doesn't go into any detail. It mentions patterns for unit testing, but directs the reader elsewhere for more information. It touches on Test Driven Development, but doesn't really follow it through. Even so, it's still a very useful book.
I would like to see an update to cover areas such as integrating NUnit with VS2010 and TFS, so that users of NUnit get the full advantages of the Test Impact Analysis, Code Coverage Analysis etc that is possible with VS2010. But, although that's important, this is still a good book.