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


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


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.


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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.