views:

530

answers:

8

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?

+3  A: 

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.

pgb
I know that tdd is not something new but this book is 2002. Is that the version you have? If so, do you think it's oudated in terms of tdd today? I know some books stand the test of time.
CoffeeAddict
I second this recommendation as it gives direct code samples that you can follow along with with your IDE of choice.
Jon Erickson
It is the version I have, and I don't think it's outdated.The examples may use an older version of JUnit, but the introduction to TDD is great.
pgb
I dont think it HAS to be MVC related. +1 for the Kent Beck book
Perpetualcoder
+1  A: 

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

Ray Tayek
+2  A: 

I'm a big fan of the Pragmatic Press books

Pragmatic Unit testing in C#

sal
I recommend this book too. Just bought it and don't regret one cent!
Andrei Rinea
+4  A: 

the art of unit testing

http://www.artofunittesting.com/

Oscar Cabrero
+1  A: 

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)

Nathan Southerland
what if I'm using NUnit, would this still be a decent book on concepts?
CoffeeAddict
Yes, xUnit refers to the entire family of unit testing tools as well as the original unit testing framework for Smalltalk. All of them are slightly different in implementation, however - so jUnit will have slightly different functionality than nUnit which will be different from , etc. Still the basic functionality and underlying principles are common to all of them.
Nathan Southerland
+2  A: 

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.

Theo Lenndorff
I just bought Pragmatic Unit Testing in c# with NUnit and I love it!
Andrei Rinea
The go for XUnit Test Patterns! You will praise it!
Theo Lenndorff
A: 

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)
eKek0
+7  A: 

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.

GuyIncognito