What is the code coverage tool ? (Part1)


Code coverage is the process of doing analysis in C# unit test code to find out which block or statement of code is executed or not.

The basic code coverage criteria are

1. Function coverage
2. Statement coverage
3. Branch Coverage
4.Conditional Coverage

There are so many tools available for this task

1. Visual Studio code coverage (Only in enterprise edition)
2. NCover
3. JetBrains dotCover
4. OpenCover
5. NCrunch
6. NDepend

I had gone through the few important code coverage tool

1.Visual Studio code coverage (Only in enterprise edition)

>> In visual studio enterprise edition default code coverage tool will be there. Since i am not using the enterprise version, I did not do deep on analysis on this tool. If you are using the enterprise edition you can go through the below URL

https://msdn.microsoft.com/en-IN/library/dd537628.aspx

2. NCover Code Coverage
>> Ncover is third party tool for visual studio.It is not the free tool. For this we have to download the software from given below URL

http://www.ncover.com/products/desktop

This tool is very straight forward to use. Firstly we have to install the tool then we will get the Ncover Menu in visual Studio.
Click on Ncover Code Coverage then you will get the Ncover Test Runner. It will load all the test case written in your application

Here i have written the test code like this

In the above test method, it will run only else condition so we are not testing the code of if condition. So if we will run the NCover tool it will show covered code as green and not covered code as red as given in above image.

It helps to find out the uncovered code in test application. This tool has also option to view the result on Desktop. It has also option to download the report in different format like html,Json and XML.

Advertisements
Posted in Tools. 1 Comment »

One Response to “What is the code coverage tool ? (Part1)”

  1. Code Coverage Tool (Part 3) | Chandradev's Blog Says:

    […] NCover Code Coverage Tool DotCover Coverage Tool […]


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: