tags:

views:

359

answers:

4

Can you recoment a book on on Unit Testing and TDD for C# with at least some treatment of Mock Objects?

I have seen this question but it does not seem to mention mocking.

+4  A: 

Have a look at Growing Object-Oriented Software, Guided by Tests by Steve Freeman and Nat Pryce - a work in progress, but free online. The code examples are in java, which shouldn't be a problem if you're a C# developer, and does focus extensively on Mocks.

Bayard Randel
Due out in the US November 2009.
Steve Freeman
+3  A: 

In my opinion, Pragmatic Unit Testing in C# with NUnit, 2nd Edition is the best introduction to Unit Testing. It's got a chapter on Mock Objects as well.

Praveen Angyan
Having written the original paper on Mock Objects (and an upcoming book), I don't this is a good introduction to the concept. They emphasis the isolation of external resources, rather than the effect on the design of the code.
Steve Freeman
+3  A: 

The Art of Unit Testing: With Examples in .NET by Roy Osherove (Amazon Page, Official Site) sounds like what you're looking for. He devotes one chapter introducing the concepts of stub and mock objects (using a "roll-your-own" approach), and then a second chapter on using mock object frameworks, particularly Rhino Mocks. There is somewhat less emphasis on Test-Driven Development, but there is quite a lot of information about TDD available from other sources, and TDD isn't all that language-specific.

glaxaco
It's a solid book, and if you're looking for info on Mock's then it's good to know that Roy Osherove is the chief architect of TypeMock
STW
Roy has a straightforward introduction to the concept. We disagree strongly on where to go after that, but that's another discussion :)
Steve Freeman
@Steve, what are the principal sources of discord?
Dan
+1  A: 

XUnit Test Patterns has a couple of sections on Test Doubles, including Mocks. Not C# specific, but does contain C# examples.

Colin Desmond