Tuesday, June 21, 2011

Ncover Command Line For MSTest

If you are using MSTest here is the command windows batch command to generate test results

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer: \yourTestProjectPath\YourTests.dll /testcontainer: \yourTestProjectPath2\YourTests2.dll /resultsfile:results.trx /testsettings:YourTestSettingsPath \local.testsettings


You can add several test projects using /testcontainer: argument. Here I have used two test projects. To use NCover we need to change this command by adding NCover commands . NCover arguments are started with “//” and for MSTest they started with “/”. Here Is the Ncover command to generate coverage.nccov and coverage.trend files.

"C:\Program files (x86)\NCover\NCover.Console.exe" "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" //x mstest_coverage.nccov //at "coverage.trend" /testcontainer: \yourTestProjectPath\YourTests.dll /testcontainer: \yourTestProjectPath2\YourTests2.dll /resultsfile:results.trx /testsettings:YourTestSettingsPath \local.testsettings


There are more options with NCover you can find those here Ncover command line

Now we have coverage.nccov and coverage.trend files we need to generate a HTML report from these two. For that we can use Ncover Reportng tool. Here is the Command to generate NCover HTML reports.

ncover.reporting mstest_coverage.nccov //lt coverage.trend //or FullCoverageReport:Html:output

Here we are generating full Coverage report in the directory called output

5 comments:

  1. Thanks for the advice via the email I sent. I finally got it working, but not sure what actually fixed it.

    What do you recommend is the best way once it's running to display/parse the data?

    Also, I am getting this error. Is there a way to change the c:/ to a different location?

    ReplyDelete
  2. Ah nice to hear that anyway. I don't really understand here what you are asking me to suggest about.
    Yes you can change the paths where ever you have installed your applications.(Is that what you want ?)
    You can always set the path variable in for MSTest and NCover with your command prompt.
    and have a clean NCover command like this,
    ncover mstest //x mstest_coverage.nccov //at "coverage.trend" /resultsfile:results.trx /testsettings:yourSettings.testsettings /testmetadata:yourProject.vsmdi

    ReplyDelete
  3. Hi, I am very new Ncover Tool.
    Can you please help me on how to work with Ncover V4 (desktop) commandline using MSTest.

    It will be appreciate if you replied as earlier.

    Thanks alot

    ReplyDelete
    Replies
    1. @SNSR,
      What kind of help you need ? I can help, if it is possible.

      Delete
  4. I would like to generate coverage.nccov and coverage.trend files using Ncover4 command line.
    i need command line syntax for the same.

    ReplyDelete