Mocking .NET Without Hurting Its Feelings

This page is for a talk I'm presenting at various technical conferences and groups.

This talk covers the two types of mocking frameworks (constrained and unconstrained), digs into how they do their magic, and discusses their pros, cons, and limits.

Session Abstract:

Unit testing has become an accepted part of our lives as .NET programmers. To help focus our tests to only the code we want to validate, Mocking Frameworks are a powerful tool in our toolbox. Like many tools, if you have an understanding of how the tool works under the hood, you can bend it to your will (and also know where it'll break if you bend too much).

In this session, you'll learn about the two main types of mocking frameworks: constrained frameworks (like RhinoMocks and Moq) and unconstrained frameworks (such as Typemock Isolator and Telerik JustMock). I'll dig into how the two actually do their magic and we'll discuss the pros, cons, and limits of both. We'll look at examples of how to use the frameworks in your tests, mocking out dependencies from your own code and even third-party logic.

You'll get the most out of this session if you're comfortable reading C# code and have a general understanding of class inheritance in .NET, along with some experience writing and running unit tests. Prior experience using mocking frameworks is not necessary.

Related Pages:

General:

Companion Example Project:

Framework-specific:

Popular Constrained Frameworks:

Popular Unconstrained Frameworks:

Bonus: The one to watch:

Other References:

Recommended Reading:

I'm a huge fan of unit testing and have found Test Driven Development to be my preferred development style. In this book, Osherove walks through the fundamentals of automated testing, including unit testing and mocking frameworks, common terminology, patterns and approaches to writing meaningful and maintainable tests. I read this book with my team and it help set a common understanding and vocabulary for how we approach automated testing.

Upcoming Presentations:

TechBash
OCT 2-5, 2018

Interested in having me present this talk at your usergroup or conference? Let me know!


Recent Version of Slides:

Legal disclaimer: Since the original posting of this and related pages, I was granted a Community license, at no cost, to Typemock Isolator. See my Disclosures & Legal page for details on my acceptance and disclosure of free products.