Better Unit Testing with Microsoft Fakes guide … “shipped”!

imageWe are pleased to announce v1 of the Better Unit Testing with Microsoft Fakes guide, under Visual Studio Test Tooling Guidance, which allows you to get familiar with the Microsoft Fakes framework, to be in a position to promote, position and use it effectively.

This eBook contains practical guidance for migrating to and unit testing with Microsoft Fakes. Practical walk-throughs allow you to navigate basic and advanced concepts, giving you a comfortable and confident start in implementing Microsoft Fakes as a mocking solution.

image

We would appreciate your candid feedback on the new guide eBook style we are dog fooding, which combines the guidance, hands-on labs and quick reference sheets into one guide. v1 includes a PDF suitable for your PC and Surface, but we are planning to add more eReader formats, i.e. EPUB/MOBI, in the near future to ensure you can peruse the guide on other devices.

Team

A huge THANK YOU to the team that created this release:

Brian Blackman, Carsten Duellmann, Dan Marzolini, Darren Rich, David V. Corbin, Hamid Shahid, Hosam Kamel, Jakob Ehn, Joshua Weber, Mehmet Aras, Mike Fourie, Patricia Wagner, Peter Provost, Richard Albrecht, Richard Fennell, Rob Jarratt, Shawn Cicoria, Waldyr Felix, Willy-Peter Schaub

Extract (Foreword)

For modern development teams, the value of effective and efficient unit testing is something everyone can agree on. Fast, reliable, automated tests that enable developers to verify that their code does what they think it should, add significantly to overall code quality. Creating good, effective unit tests is harder than it seems though. A good unit test is like a good scientific experiment: it isolates as many variables as possible (these are called control variables) and then validates or rejects a specific hypothesis about what happens when the one variable (the independent variable) changes.

Creating code that allows for this kind of isolation puts strain on the design, idioms, and patterns used by developers. In some cases, the code is designed so that isolating one component from another is easy. However, in most other cases, achieving this isolation is very difficult. Often, it’s so difficult that, for many developers, it is unachievable.

First included in Visual Studio 2012, Microsoft Fakes helps you — our developers — cross this gap. It makes it easier and faster to create well-isolated unit tests when you do have systems that are “testable,” letting you focus on writing good tests and not on test plumbing. It also enables you to isolate and test code that is not traditionally easy to test, by using a technology called Shims. Shims use runtime interception to let you detour around challenging dependencies and replace them with something you can control. As we have mentioned, being able to create this control variable is imperative when creating high-quality, fast-running unit tests.

Shims provide a very powerful capability that will let you circumvent all kinds of roadblocks when unit testing your code. As with all powerful tools, there are a number of patterns, techniques and other “gotchas” that can take time to learn. This guidance document provides you with a jump-start on acquiring that knowledge by sharing a large number of examples and techniques for effectively using Microsoft Fakes in your projects.

We are happy to introduce this excellent guidance document produced by the Visual Studio ALM Rangers. We are sure that it will help you and your team realize the power and capabilities Microsoft Fakes provides you in creating better unit tests and better code.

Peter Provost – Program Manager Lead, Visual Studio ALM Tools

Joshua Weber – Program Manager, Visual Studio ALM Tools