TechBubbles Microsoft Technology BLOG

Visual Studio 2012 Testing Features for Developers

Developer Testing in Visual Studio 2012 has been improved a lot and it is allowing them to concentrate more on the code they are writing in the application. In addition to the testing framework that comes with Visual Studio 2012, you can easily add third-party testing frameworks in the IDE. This post discusses the new unit and integration testing features for developer in Visual Studio 2012. image

To open the new Test Explorer window, Select the Test Menu then choose windows and click Test Explorer

image

The look and fell of Test Explorer in VS 2012 is different in number of ways. You do not have too many different windows to say same information in new IDE, instead you have one widow that focus on unit and integration testing results.

image

When you select a test case in Test Explorer then you can see the detailed information about the test in below pane. The green bar in test explorer gives you quick view on the out-come.

Integrating Third Party Testing Frameworks

One of the important feature for developers for testing in this release is, it enables you to quickly integrate third-party testing frame-works in VS 2012. So If your team uses N-Unit or XUnit.net or some other testing framework then you can simply install Visual Studio extension.

To open the Extension tools manager, Go to Tools and click Extensions and Updates

image

You can search the framework that you need and download as shown below

image

In Visual Studio 2012 Regard less of which Testing Framework you use, it is fast and scales  up to thousands of test cases.

Developer testing is also very easy to use, If you want to Run or Debug the test that is in your editor then you can right-click on the code and select either run tests or debug tests.

image

You can also Filter the test cases by entering the search term in Test Explorer. You can also group tests with different properties, You can group the tests either by Test Outcome or Duration.

image

If you often require to run unit and integration tests in your solution then with single click in Visual Studio 2012 you can accomplish with Run test after build feature.

image

Now your test will run as part of every build you do.

With a single-click you can analyze and understand various code-metrics about your solution.

image

The Code Metrics Results window will appear as below information like number of line of code , Class Cohesion and Depth of inheritance

image

As it in previous visual studio versions, you can use Code Analysis Tool to quickly find common coding and design mistakes in your code

image

Another new feature in Visual Studio 2012 is Code Clone Analysis, using this feature you can scan your entire solution for duplicate code

image

Code Clone Analysis is smart enough to identify the duplicate code and groups the results with Exact match and medium match.

You can also use code clone feature that matches selected code in editor as shown below

image

Code Coverage Analysis

Code Coverage Analysis tool helps you to know how well your tests exercise your code? Code Coverage Analysis has significantly improved in Visual Studio 2012. To Analyze the code coverage of all the tests in your solution simply click Run drop down in Test Explorer

image

You can browse and explore the Code Coverage Results after completing the run

image

Unit test cases can also run in isolated mode with fakes framework, more information on this can be read here

Reference: Peter Provost’s talk on Visual Studio launch


Share this post :

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

Add Comment

By Kalyan Bandarupalli
TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud