Unit Testing Improvements in Visual Studio 2011

In the past, one big reason why people did not embrace MS Test (I think) is because Visual Studio 2008/2010 did not provide a good environment that supported Unit Testing. Sure it did had MS Test and its runner, but it was weak compared to Test Runner from Jet Brains ReShareper or TestDriven.net. I think someone at Microsoft listened to and as I result, there is many notable improvements in this area in Visual Studio 2011.

Below screenshot shows Visual Studio 2011 with Unit Testing related Menu marked.
Under Run Unit Tests, options are all self explanatory.

Menus shown below:

There is an option Unit Test > Unit Test Setting called “Run Tests after Build”, using by which you can always run all the unit tests after each time you build. This is a good practice, and if you manage it well i could be useful. Personally I think I would always kick off my test/s manually, its just my preference now. Also I would have a well scripted local build that can take care of building all components and running my unit and integration tests automatically.

BYO TF (Bring your own Test Framework)

I am not a fan of Ms Test (I think I made that clear earlier), I use NUnit and I have no idea to switch to another framework. What I like about this edition of Visual Studio, is that, it supports other testing frameworks like NUnit through test adapters. If you are using NUnit like me, download NUnit Test Adapter from here > Link
Visit this page for information on all available at this time > Link

Another way of getting third party frameworks is to use the Extension Manager, Click on Tools > Extension Manager to launch extension manager, then under Online Extensions, Expand Visual Studio Gallary, Select Tools, and click on Testing.

Test Explorer

Test Explorer lists all the Tests grouped by Failed, Passed, etc. You can right click and run individual tests, or debug tests.

Code Coverage

Visual Studio 2011 packs a code coverage tool also. This is a great feature addition. In the past, I had to purchase a tool like dotCover to do this for me. By double clicking on each line in the coverage results window, you can inspect the parts of your code that lacks coverage (or be proud to see every piece of code has 100% coverage and green)

More later, Happy Coding

One comment

  1. spiceness

    At present, there’s no test nesting unlike with Resharper’s test runner. My solution with several thousand tests is rather unnavigable.
    Let’s hope MS make some improvements in this area and provide a tree structure so that groups of tests can be run in isolation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s