Better Unit Testing with Microsoft Fakes

Better Unit Testing with Microsoft Fakes is a free e-book that discusses the topic of Microsoft Fakes. Microsoft Fakes is a code isolation framework for Visual Studio that helps you isolate the code for unit testing by replacing other parts of the application with stubs or shims. With Microsoft Fakes you can test parts of your software even if some parts have not been implemented or are not working yet.

Better Unit Testing with Microsoft Fakes has been written by the Visual Studio ALM Rangers, a group of contributors that are experts in Visual Studio technologies. The book starts with an introduction to unit testing strategies and how it should impact the design of your code. Then the book presents the Microsoft Fakes approach and framework that comes in two flavors: the stubs and the shims.

Better Unit Testing with Microsoft Fakes
The stubs replace a class with a small substitute (“stub”) that implements the same interface. The shims modify the compiled code at run time, to inject and run a substitute (“shim”). Both mechanisms are described and some hints are provided about how to choose between a stub and a shim. This solution is compared to traditional mocking strategies used in .NET and information is provided on how to migrate from a mock approach towards fakes. The book is completed by technical presentation about the efficient usage of fakes and a hand-on lab.

This is very interesting book that I will recommend to anybody involved with coding and software testing in the .NET world.

The book in various formats (pdf, epub, mobi) and the code for the lab can be freely downloaded from

Related Content: