Code Coverage Tool (Part 3)

This is the last part of code coverage tool, in this post we will see the open source code coverage tool,i.e. OpenCoverage which is light weight and totally free to use. Which will give almost all functionalities as similar to third party code coverage tool (Ncoder and DotCover)

NCover Code Coverage Tool
DotCover Coverage Tool

How to use OpenCover tool?

Step 1: Create some demo unit test case in visual studio. I have written some dummy unit test case as given below

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestCase_Sample
    public class UnitTestCaseDemo
        public void AdditionOfTwoNum()
            var a = 0;
            var b = 0;
            if (a!=0 && b!=0)
                var result = a + b;
                Assert.AreEqual(30, result);
                var result = a + b;
                Assert.AreEqual(0, result);

        public void SubstractionOfTwoNum()
            var a = 20;
            var b = 10;
            var result = a - b;
            Assert.AreEqual(10, result);

        public void MultiplicationOfTwoNum()
            var a = 20;
            var b = 10;
            var result = a * b;
            Assert.AreEqual(200, result);

        public void DivisionOfTwo_Num()
            var a = 20;
            var b = 10;
            var result = a / b;
            Assert.AreEqual(2, result);

        public void Addition_Of_ThreeNum()
            var a = 10;
            var b = 20;
            var c = 30;
            var result = a + b + c;
            Assert.AreEqual(60, result);

        public void Test()
            int i = 10, j = 0;
            int x;
            x = i / j;

Step 2: Download the OpenCover UI from Microsoft store, from the given below URL

In Visual Studio Tab will show like this

Step 3: Right click on solution explorer and click on Manage NuGet Packages and Install the OpenCover and ReportGenerator in your application as given below

Step 4: Go to Visual studio Tool ->> Options ->> OpenCoverUI Options then select the OpenCover.Console.exe from your application.

Step 5: Go to OpenCover tool of Visual Studio and Select OpenCover Test Explorer and select the test cases to be run like given below Image

Now we will get output like given below

In the above result it is showing that how much code has been covered in which test case.

If you have to fix the problem then just double click on given method, you will see the code like this given below image

This indicate that below code branch has not been executed. So we have to write the other unit test case to cover above code.

How to get the report as third party control as similar to Ncover and DotCover

For getting the report in user friendly manner we have to take help of Report Generator Tool.
For that we have to create the .bat file, which will generate the report in given folder.

Firstly create the notepad file keep this syntax as given below

"C:\Source\Test \packages\OpenCover.4.6.519\tools\OpenCover.Console.exe" -register:user -target:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe" -targetargs:"/noisolation /testcontainer:\"C:\Source\Test \Test\bin\Debug\Test.dll\" /resultsfile:C:\Reports\MSTest\.trx" -mergebyhash -output:C:\Reports\MSTest\projectCoverageReport.xml

"C:\Source\Test \packages\ReportGenerator.2.5.2\tools\ReportGenerator.exe" -reports:"C:\Reports\MSTest\projectCoverageReport.xml" -targetdir:"C:\Reports\CodeCoverage"

Now save the file as .bat extension and run the bat file.

Note: Before running the bat file, please create the Reports\CodeCoverage and MSTest directory in C folder.

Now go to the CodeCoverage folder and see the report after clicking on Index.html file like as given below

In the above tools compare we show that OpenCover contains almost all the major features which contains all the paid version tools and it is very light weight and flexible to use in any project.

Comparison between all the Tools

How to set up the last page read on adobe pdf reader

if you are reading some eBooks using adobe pdf reader, you have completed some page like 20 or 30 in one days. Again if you have to read after few days then if you will open the same book, then it will open from first page, It is very horrible experience.

Now you can fix this problem like this

Step 1: Go to Edit Menu

Step 2: Click on Preferences in your Adobe PDF Reader

Step 3: Select Document tab and check the “Restore last view setting when reopening documents.”


How to use Corflags tool of Visual Studio to check 32/64 bit of dll ?


Corflags is the inbuilt tool of Visual Studio which is used to find out the type of .dll i.e 32 bit, 64 bit or any CPU. This tool is available in Visual studio 2005 onward. i.e. VS 2005/2008/2010/2013

These are the following steps to check in Visual Studio

Step1 : Go to visual Studio command prompt like this


Step 2: Make Sure that Corflags is working in your system

Type the Corflags in Command Prompt like this


Note: if this syntax is not working then there is some problem in Environment Variable of the System
You can fix this issue like this post

Step 3: Go to the file Location of DLL and type the syntax like this in below image
Corflags AjaxToolKit.dll


This is the short summary to determine the type of dll

Any CPU: PE = PE32 and 32BIT = 0
x86 bit: PE = PE32 and 32BIT = 1
64-bit: PE = PE32+ and 32BIT = 0

I hope this will help to some body.

Code Cleanup free tool for Visual studio 2010/12


Recently i was doing code cleanup of my project. I was searching some tool for this work then i got very nice tool. It is really very useful tool for developer. You also just try it.

You can download from here

You can read the documentation from here

I hope it will help to other developers.

Free eBook on Visual Studio 2012 from Telerik


Here is the excellent free eBook on Visual Studio 2012 from Telerik publication. Here you will learn all the new features of VS 2012 in very easy ways. It is completely free to download.

Free eBook on VS 2012 from Telerik download link

I hope you will enjoy while reading this book.

How to make cross browser compatibility of website?

Some many time, while developing web based project, It will look proper on one browser,but it doesn’t look proper on other browser. I had faced this problem so many time.

Here is some free tools which will help to check the XHTML and CSS standards.

If we don’t follow this standard then it will not look proper on all browser.

To validate HTML and XHTML

To validate CSS

Free web Template