get code coverage percentage in cruisecontrol.net c#

I am trying to get code coverage in cruisecontrol.net. 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"/>
  </exec>
</target>

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