6

Using the C++ unit testing framework with Visual Studio 2013 Professional, one can write unit tests and run them from within the IDE, but in order to generate any coverage reports, apparently, one needs to have the Premium or Ultimate edition of Visual Studio.

Is it possible to get code coverage reports with the Professional edition, preferably without installing any third party tools? If not, what alternate options exist for people who are not using the more expensive editions of the IDE?

Please note that it's possible to generate the coverage data by using command line tools, but I am unable to find a way to look at the results. For the sake of reference, here are the steps for command line generation of the coverage statistics:

  1. Build the code to test with with /PROFILE linker switch
  2. Run vsinstr /coverage <binaryName> to instrument the code; make sure that you are inside VS 2013 command prompt
  3. Run start vsperfmon -coverage -output:results to run the profiler
  4. Run your unit tests
  5. Stop the profiler by running vsperfcmd -shutdown

The above will give you a results.coverage file, with no way to view it without the Premium or Ultimate editions as far as I know.

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
Jaywalker
  • 3,079
  • 3
  • 28
  • 44

3 Answers3

7

With VS2013 Professional you are out of luck if you want to do it without third party tools Requirements: Visual Studio Ultimate, Visual Studio Premium (http://msdn.microsoft.com/en-us/library/dd537628.aspx). From what I understand you already managed to generate your *.coverage file and you are having problems opening it. Visual Coverage (https://github.com/jsargiot/visual-coverage) tool can help you with that, its very simple to use and it is opensource. If you would like to find more alternatives, see another SO thread: Viewing Code Coverage Results outside of Visual studio. The tools are meant for C# coverage files but from what I understand there should not be any difference.

Community
  • 1
  • 1
N A
  • 656
  • 3
  • 6
  • 2
    The so called opensource `Visual Coverage` tool shamelessly includes two MS DLL's, which **I believe** are not open for redistribution. The `ReportGenerator` tool requires XML coverage data, which is not available outside Premium and Ultimate, I believe. – Jaywalker Oct 21 '14 at 15:53
3

If you are ready to use third-party libraries, you can use OpenCPPCoverage. It works for me like a command line app. But I couldn't run it like a visual studio plugin at Professional Visual Studio 2013.

Jimilian
  • 3,859
  • 30
  • 33
  • 2
    Well, as of today you *can* use it as a Visual Studio (Community+) plugin; I just finished implementing it and decided to share: https://github.com/atlaste/VSOpenCPPCoverage . Works out-of-the-box with MSTest and custom executables (which is basically what I use :) – atlaste Jun 08 '16 at 15:56
1

One possible way you could get coverage data is by running an instrumentation toolkit on your Unit Test program. The instrumentation tool will tell you how much was covered during execution and you can easily relate this data back to how much coverage your unit tests give you. I did this with an XCode project and OpenPAT but you could do the same with any Visual Studio friendly toolkit.

BlamKiwi
  • 2,093
  • 2
  • 19
  • 30
  • Are there any known "Visual Studio friendly toolkits" which do the same? – Jaywalker Oct 22 '14 at 15:53
  • In a project I've used this profiling tool http://www.glowcode.com/summary.htm. Unfortunately I haven't found anything like OpenPAT or Valgrind for windows. – BlamKiwi Oct 22 '14 at 21:40