Pages

Saturday, February 21, 2015

Code Quality and Test Coverage using NCover

For any Developer the code quality is at most important, every organization put emphasis and focus on a very good code quality whether it is a Product based company or a service organization. All the process which we follow to improve the Quality are mainly focused on finding defect if at all any present in the code and fixing them ASAP.

Now days everyone is going for agile methodology, which is one of the best methodology to improve the code quality and deliver highly efficient code. Agile also force to make most of the automation test so that in a quick time limit we can have maximum code tested.

Then the Question arises:-

How much code is covered in or test case?

How Can I Cover entire code in test case?

What can be done to reduce less tested code?

In this case we go for a Test coverage tool or option which will give some figures and facts that how much percentage of the code is tested, covered and left untouched. There are a l lot of statistics and measurement required to baseline the approach and finalize that we are having maximum code coverage.

There are a lot of test coverage tools are present in the market. Recently I came across one of them and I was really happy with the result it has given to me. That tool is NCover. NCover provides a very powerful and flexible tool set which can integrate into your build process and help you deliver higher quality code. The flexibility provided by the NCover tools may seem a little intimidating at first, but with a little experimentation it is easy integrate NCover with any build process. 

The latest version of NCover is NCover 5. I have tried this application with some of my application and I am pleased with the kind of response it has given to me. Some of the latest features added in NCover 5 are


      1.       Improved static analysis for expanded merging

2.       Public browsing of code central projects

3.       Enhancements to ncover user interface
 
4.       Pre-instrumentation
 
5.       Coverage for windows store apps
 
6.       Condition coverage
 
7.       Baseline executions
 
8.       Self-contained html report
 
9.       Expanded coverage data exporting
 
10.   Visual studio theme support
 
11.   Expanded test runner support
 
12.   Improved bolt performance




Implementing Code Coverage using NCover.


NCover performs analysis on code by instrumenting it behind the scenes while the tests are running. If using NUnit as the unit testing tool, simply prefix the NUnit command line with the NCover command.
NUnit command line:

nunit-console MyTests.dll

NUnit with NCover:

NCover.Console nunit-console MyTests.dll

It's easy enough to create code coverage data, but analysis is where you actually begin to improve your tests. We include NCoverExplorer with NCover for this purpose. NCoverExplorer highlights those lines of your code that are uncovered, and does statistical analysis of your coverage data as well. It can even run a program and collect coverage data for you, so many developers never touch the command line version of NCover. NCover also includes an HTML reporting feature for teams that want to generate analysis reports including highlighted code directly from their continuous integration server


Some of the GUI option for NCover are








You can download the Trail version from Below location. NCover Download. For more details Please visit the below location. https://www.ncover.com/support/docs/index.  I  hope you will like using this tool and improve the quality of the code. Please provide your feed back for this article or any more support on the NCover tool. I will try to resolve them or will take them directly to the NCover team.

Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC, DNS MVM




Kontera