The code coverage tool in Visual Studio 2008 Team System is quite easy to use from within the IDE unless you want code coverage for your native C++ code. In order to generate a code coverage report for native C++ you have to use the command line tools. This is how you do it:
So now you know how to get coverage reports for native C++ using Visual Studio 2008 Team System (if not
Thanks,
This was extremely helpful and your instructions were spot on.
Cheers
Karan
Nice work. This really helped.
One thing that I have found: you can seemingly get overall numbers in Release builds, but you will get more itemized results (per class/method) in Debug mode. Is this correct?
@ Kirk:
I guess your observation is correct, typicaly since releasebuilds are optimized while Debug builds are not (since you in Debug builds want to preserve the code structure to make step by step debugging meaningful).
I *think* the tool for instrumenting is vsinstr.exe rather than vsinst.exe. That's what I've got on my machine, anyway.
Eric
Eric, you're right. I have updated the text.
I found out to get the code coverage with visual studio for c++, I have to use the two files "vinstr" and "vsperfmon". I cannot find these files in my local installed version of visual studio ("performance tool" is not existing).
Where can I get these two files?
andreas.bittel@cdn-automotive.com
tia
Regards
Andreas Bittel
@Andreas Bittel: Assuming VS2008 you need either the team suite or the test version (I think the code coverage is part of the test version as weel as the team suite). You cannot use any version of VC++.
I guess that even if you have the team suite, there is a possibility to not install the code coverage tool too.
Thanks for the explanation.
I finally got it setup in my project. My project has multiple unit tests, with each test file compiled into an executable. After I run those files, I got a single .coverage file. When I loaded into Visual Studio, it displays the coverage under each executable. I could not find a way to display coverage in a merged manner. For example, a.cpp have a coverage of 20% under test1.exe, 30% under test2.exe. I am interest to see the overall coverage of a.cpp.
@Sherwood: Sorry no experience there. I'm using Bullseye for coverage wich has a better way of showing a merged result.
Hi when i am running the 5th step i am getting error saying"This application has failed to start because VSCover90.dll was not found.Re-intalling the application may fix this problem."
How to fix the above error.
Pavan
I'm totally impressed by the code coverage for C/C++ using your method. It's not very convenient to use the command line (and I'd say someone should write an Add-In for this functionality) but the later on nice visualization in the VS editor is absolutely worth it.