Tuesday, March 12, 2013

Better Unit Testing with Microsoft Fakes guide

The ALM Rangers did it again. Last week they released a new guide:  Better Unit Testing with Microsoft Fakes. This guidance document provides you with a jump-start for effectively using Microsoft Fakes in your projects.

Microsoft Fakes 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.

No comments: