get code coverage percentage in c#

I am trying to get code coverage in Using the following NANT script:

<target name="code_coverage" description="finds the code covered with tests">
  <exec program="${vstest_console}">
    <arg value="/Settings:CodeCoverage.runsettings" />
    <arg value="/EnableCodeCoverage" />
    <arg value="Tests.dll"/>

I am able to get a .coverage file. First of all the name of the .coverage file is coming as user name appended with current date time and under a folder named randomly. In .runsettings file documentation, i was unable to find anything about changing the name of .coverage file or changing the path. I need to change name of this file and the path.

Secondly can somebody help me in extracting covered path percentage out of this. I just need to fail the build, if coverage is below a point. Lot of help is available on Google but is of VS 2010 and before. I need help for VS 2012 or VS 2013. Currently am working on VS 2013 Ultimate and am using .runsettings file for code coverage.

Source: .net

Leave a Reply

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