Monday 16 April 2012

Run alternative unit test frameworks from Visual Studio 11

With Visual Studio 11 the whole set of testing features has been trashed out and remodelled upon a completely new shape.

If until Visual Studio 2010 you had as a default and mandatory choice MSTest (apart from the fact that you could patch-and-try another test framework, but that was not for mainstream developers IMHO, and moreover it was out of the IDE itself) from Visual Studio 11 on you can choose whatever testing framework you want.

The magic running underneath is quite simple. If before MSTest was just the way to do, now the whole test runner and all the testing tools rely on a brand new pluggable layer, which means you can plug-and-play (it sounds so Windows 95ish, isn’t it? Smile) NUnit, xUnit.NET, and all the frameworks that will provide a plugin to integrate in Visual Studio 11.

This is true on a test project, but even inside a test class!

To add support to other test framework is astonishingly easy: you just have to add them via NuGet:

image

image

Then you can remove the Microsoft.VisualStudio.TestTools.UnitTesting reference from your code, add the NUnit (or whatever) one, and start writing down tests as you always did with your favourite testing franework.

No comments:

Post a Comment