Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:23:24+00:00 2026-05-24T03:23:24+00:00

I was wondering if any of you guys had any experience generating code coverage

  • 0

I was wondering if any of you guys had any experience generating code coverage reports in TFS Build Server 2010 while running NUnit tests.

I know it can be easily done with the packaged alternative (MSTest + enabling coverage on the testrunconfig file), but things are a little more involved when using NUnit. I’ve found some info here and there pointing to NCover, but it seems outdated. I wonder if there are other alternatives and whether someone has actually implemented this or not.

Here’s more info about our environment/needs:
– TFS Build Server 2010
– Tests are in plain class libraries (not Test libraries – i.e., no testrunconfig files associated), and are implemented in NUnit. We have no MSTests.
– We are interested in running coverage reports as part of each build and if possible setting coverage threshold requirements for pass/fail criteria.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:23:26+00:00Added an answer on May 24, 2026 at 3:23 am

    We ‘ve done it with NUnit-NCover and are pretty happy with our results.
    NUnit execution is followed by NUnitTfs execution in order to get our testing results published in the Build Log. Then NCover kicks in, generating our code coverage results.

    One major thing that poses as a disadvantage is fact that setting up the arguments for properly invoking NCover wasn’t trivial. But since I installed it, I never had to maintain it.

    Two things could pose as disadvantages:

    • NUnitTfs doesn’t work well with NCover (at least I couldn’t find a way to execute both in the same step, so (since NCover invokes NUnit) I have to run Unit tests twice: (1) to get the test results and (2) to get coverage results over NCover. Naturally, that makes my builds last longer.
    • Setting up the arguments for properly invoking NCover wasn’t trivial. But since I installed it, I never had to maintain it .

    In any case, the resulting reporting (especially the Trend aspect) is very useful in monitoring how our code evolves within time. Especially if you ‘re working on a Platform (as opposed to short-timed Projects), Trend reports are of great value.

    EDIT
    I ‘ll try to present in a quick & dirty manner how I ‘ve implemented this, I hope it can be useful. We currently have NCover 3.4.12 on our build server.
    Our simple naming convention regarding our NUnit assemblies is that if we have a production assembly “123.dll”, then another assembly named “123_nunit.dll” exists that implements its tests. So, each build has several *_nunit.dll assemblies that are of interest.

    The part in the build process template under “If not disable tests” is the one that has been reworked in order to achieve our goals, in particular the section that was named “Run MSTest for Test Assemblies”. The whole implementation is here, after some cleanups to make the flow easier to be understood (pic was too large to be directly inserted here).

    At first, some additional Arguments are implemented in the Build Process Template & are then available to be set in each build definition:
    enter image description here

    We then form the NUnit args in “Formulate nunitCommandLine”:

    String.Format("{0} /xml={1}\\{2}.xml", nunitDLL, TestResultsDirectory, Path.GetFileNameWithoutExtension(nunitDLL))
    

    This is then used in the “Invoke NUnit”
    enter image description here

    In case this succeeds & we have set coverage for this build we move to “Generate NCover NCCOV” (the coverage file for this particular assembly). For this we invoke NCover.Console.exe with the following as Args:

    String.Format("""{0}"" ""{1}"" //w ""{2}"" //x ""{3}\{4}"" //literal //ias {5} //onlywithsource //p ""{6}""",
                  NUnitPath,
                  Path.GetFileName(nunitDLL),
                  Path.GetDirectoryName(nunitDLL),
                  Path.GetDirectoryName(Path.GetDirectoryName(nunitDLL)),
                  Path.GetFileName(nunitDLL).Replace("_nunit.dll", ".nccov"),
                  Path.GetFileNameWithoutExtension(nunitDLL).Replace("_nunit", ""),
                  BuildDetail.BuildNumber)
    

    All these run in the foreach loop “For all nunit dlls”. When we exit the loop, we enter “Final NCover Activities” & at first the part “Merge NCCovs”, where NCover.Console.exe is executed again – this time with different args:

    String.Format("""{0}\*.nccov"" //s ""{0}\{1}.nccov"" //at ""{2}\{3}\{3}.trend"" //p {1} ",
                  Path.GetDirectoryName(Path.GetDirectoryName(testAssemblies(0))),
                  BuildDetail.BuildNumber,
                  NCoverDropLocation,
                  BuildDetail.BuildDefinition.TeamProject
                  )
    

    When this has run, we have reached the point where all NCCOV files of this build are merged into one NCCOV-file named after the build + the Trend file (that monitors the build throughout its life) has been updated with the elements of this current build.

    We now have to only generate the final HTML report, this is done in “Generate final NCover rep” where we invoke NCover.reporting with the following args:

    String.Format(" ""{0}\{1}.nccov"" //or FullCoverageReport //op ""{2}\{1}_NCoverReport.html"" //p ""{1}"" //at ""{3}\{4}\{4}_{5}.trend"" ",
                  Path.GetDirectoryName(Path.GetDirectoryName(testAssemblies(0))),
                  BuildDetail.BuildNumber,
                  PathForNCoverResults,
                  NCoverDropLocation,
                  BuildDetail.BuildDefinition.TeamProject,
                  BuildType
                  )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys! Was wondering is anyone had any suggestions on books or other resources
I was just wondering if Android had built in code so that I could
I am wondering if you guys have any good reading to consider what to
Just wondering if any of you guys know of any web-based/browser-based employee scheduling software/tools?
Hello guys I was wondering why some websites which uses php (or any other
Hej guys, I was wondering if you know any well working Math or Calculation
Hi there guys I was wondering if you have any suggestions on any flash
I was wondering if any of you guys have tried something about CSV migration
I was wondering if any of you guys know how to show that dashed
Hi guys I downloaded Jaspersoft ireport and was wondering if you know of any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.