2

I have 80+ VS2010 solutions, each contains some unit test projects.
All solutions are merged into one big solution before build process.
All tests (or some test subset) are executed after the successful build.

I want to enable test code coverage for all tests to get exact code coverage for all output assemblies.

My question is: how to enable code coverage without using Visual Studio?

Note: I'm using TFS2010 (MSBuild) to build merged solution. VS 2010 Premium is installed on the build server. MSTest is used for test execution.

Ludwo
  • 6,043
  • 4
  • 32
  • 48

3 Answers3

3

You can use JetBrain's TeamCity Professional. It is a CI server that supports executing unit tests and calculating code coverage. It is free for small installations.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
2

I think you need to consider deploying a code coverage tool, see here for a comparison (provided you implement .net).

We use NCover, which integrated in our TFS-Build in it's console variant and, although it's not trivial to set it up, we 're very satisfied with it.
In this post I had briefly described how we inserted NCoverin our build, this might we useful to you even if you go with another tool.

Community
  • 1
  • 1
pantelif
  • 8,524
  • 2
  • 33
  • 48
  • 1
    +1. NCover is not free, I'll try to use [PartCover](http://stackoverflow.com/questions/38360/can-you-recommend-an-alternative-for-ncover) – Ludwo Jan 10 '12 at 14:30
  • I absolutely respect what you 're saying, hope PartCover does it for you! – pantelif Jan 10 '12 at 15:18
  • 1
    @Ludwo: PartCover is no longer actively developed, you should use OpenCover instead. See [here](http://www.palmmedia.de/Blog/2011/6/21/code-coverage-testing-with-opencover-and-partcover) for more info. – Daniel Hilgarth Jan 10 '12 at 16:18
  • 2
    As @DanielHilgarth says use OpenCover over PartCover, if you are looking for free; OpenCover supports 32/64 bit processes, provides sequence and branch coverage, has silverlight support and some service support, is active (not just maintained) and will soon have coverage by test. The only thing it doesn't have is reporting, but ReportGenerator covers that (as referred to by @DanielHilgarth) – Shaun Wilde Jan 10 '12 at 20:31
  • +1 on the OpenCover/ReportGenerator combo. I've been doing some testing with Jenkins lately, and it works well. – trydis Jan 11 '12 at 15:49
2

If you create a Vsmdi file in your large solution (ms test will usually do this for you) you can use this to tell the build which assemblies you want to instrument.

This will only provide code coverage for assemblies that have tests run against them. If you're using testrun.config files to decide which tests you want to run, this should be all you need. The code coverage results should then be published to the build drop location

Edit:

This blog post looks like it covers setting up code coverage

James Reed
  • 13,873
  • 51
  • 60
  • What do you mean with "ms test will usually do this for you"? I didn't find any Vsmdi files for my merged solution. Vsmdi files are included in every solution, but these files are excluded from merging process. Can I use testrunconfig files only without vsmdi files? I'm not using drop location. Are these code coverage results stored into the MSTest results trx file or in the different file(s)? – Ludwo Jan 11 '12 at 05:15