For the past five years I've been using TDD where possible and I feel fairly comfortable and confident with the methodology.

I already know what mocking frameworks are used for but I'd like to learn more about how to use them.

Does anyone have a list of links to good examples of using mocking frameworks (including best practices, anti-patterns etc) in a real world business app. Can anyone recommend books on the topic? Any step by step tutorials?


Updated: Hah! just as I posted this someone else asked a similar question at the same time.

+16  A: 

Not to toot my own horn, but I do have a post comparing Rhino Mocks with MoQ. I need to update it as Rhino Mocks has added some new behaviors that make it more similar to MoQ, but the examples I provide are dirt simple and give you a taste of the mechanics of mocking.

One of the best articles on mocking is this one by Martin Fowler:

The thing you'll learn is that most mock frameworks support the concept of "Mocking" and "Stubbing".

+1  A: 

I've been making good use of TypeMock at work.

I've tried Rhino previously and it's certainly very good but TypeMock gives you just that bit more when it comes to working with legacy code, plus it's good to have a commercially supported product.

Their new release, Isloator 5.0 gives an additional third mocking method call AAA mocking which looks very interesting.

Also, the MSBuild tasks that come with Typemock have proved most useful.

+1  A: 

TDD - Practical Guide by David Astels uses JUnit and EasyMock to build an example application in a test driven fashion, and gives a good overview of how mock objects are used.

+1  A: 

In the Typemock Learn about .Net unit testing page you can see a Case Study by Scott Hanselman.

+1  A: 

For many tasks I use Rhino , but if you need to mock legacy code or sealed classes Typemock is better.