I need recommendations on a good Unit Testing book for use with ASP.NET MVC. Based on books you have actually read and use (your bible), what do you recommend?
I like Kent Beck's "Test Driven Development: By Example" (amazon link) as an introduction to TDD, it's not specific to C# nor ASP.NET MVC.
don't know of one specifically for that, but this is the bible: http://xunitpatterns.com/.
not a book, but maybe helpful: http://www.codeplex.com/xunit
Well, if it's bible you're looking for, check out xUnit Test Patterns by Gerard Meszaros. It's got theory, test smells, and patterns w/ examples. (That'd be the one Ray T. recommended up above.)
If you're looking for higher level tests (especially through the UI) check out the eBooks by Gojko Adzic (www.acceptancetesting.info and www.fitnesse.info)
I recommend to start with Pragmatic Unit Testing in C# with NUnit because it's easy to read and is very concrete with C# (ideal if you use C# for ASP.NET). After that go on with XUnit Test Patterns. It's more universal, gives you a lot of ideas and serves as a very good reference.
See the list of recomended books in the IEEE Software article TDD: The art of fearless programming. It has a comment and the level related to each one.
Some of them:
- Kent Beck, TDD by Example, Addison-Wesley, 2002 (introductory)
- David Astels, Test Driven Development: A Practical Guide, Prentice Hall, 2003 (intermediate)
- James Newkirk and Alexey Vorontzov, Test-Driven Development in Microsoft .NET, Microsoft Press, 2004 (intermediate)
It seems that all of the newer ASP.NET MVC books have at least one chapter on unit testing.
I have recently completed Steve Sanderson's book Pro ASP.NET MVC Framework and I thought the author placed a strong emphasis on unit testing. The book doesn't have a dedicated chapter on unit testing, but just about every chapter has relevant sections or call-outs/sidebars that deal with testing routing (inbound and outbound), controllers, repositories, model binders, etc. If I remember he uses the nUnit and Moq libraries in great detail. You can preview parts of his book on Google Books : Pro ASP.NET MVC Framework or order it from Apress (their eBooks are reasonably priced but password protected with your email address which is sort of a pain for me) or from Amazon.
I haven't seen any plans for a book solely on ASP.NET MVC unit testing, so you're going to probably have to stick to blogs or with whatever content you can find in the upcoming ASP.NET MVC books (like I said, it seems that all of them cover unit testing to varying degrees).
Some of the books that I know of:
Wrox: Beginning ASP.NET MVC 1.0 --- Has a sample chapter on testing for download here.
Manning: ASP.NET MVC in Action --- Doesn't have an explicit chapter on testing, but if you download the CodeCampServer reference application you will find a ton of unit, integration, and regression tests.
Wrox: Professional ASP.NET MVC 1.0 --- Has unit tests in the NerdDinner sample application and a dedicated chapter on testing. Testing Guru Roy Osherove (author of The Art of Unit Testing) reviews the NerdDinner tests here.
Packt: ASP.NET MVC 1.0 Quickly --- Has a chapter on unit testing and the author has a pretty good blog that talks about various ASP.NET MVC issues including testing.
Sams: ASP.NET MVC Framework Unleashed --- Browsing the Table of Contents for the book reveals a fair amount of content dedicated to testing (mocking, TDD, etc). You can check out the author's blog for sample content from the upcoming book and other ASP.NET MVC and TDD related posts.