Excluding external libraries from Code Coverage in VS2010
-
13. března 2012 20:48
Hello,
I am trying to measure code coverage of my unit tests for a code I have developed in Visual Studio 2010 Ultimate (C++). In my coverage result I can can see library functions from std, boost libraries have been included too.
I would like to exclude those from my coverage results and see the numbers only based on the code written by me. If somehow I can exclude namespace "std" and "boost", that would solve my problem.
From what I saw by searching on this; in VS2010 I can manually include/exclude a class/function/method by mentioning [ExcludeFromCodeCoverage] above its definition. Obviously I can't do that for std or boost namespaces.
Later, I came to know that VS2008 had a external tool called VSInstr.exe which would instrument my executable to ignore specified namespace as below:
VSInstr.exe /EXCLUDE:std* lib_test.exe
So, I thought I would run this command on my exe as a post-build event and then run my unit test to generate code coverage. But, after doing so, I got this error:
Warning 3/13/2012 12:46:07 PM Instrumentation error while processing file lib_test.exe:
Error VSP1018: VSInstr does not support processing binaries that are already instrumented..So, looks like VS2010 too internally runs VSInstr.exe on the binary.
Is there any way I can give my /EXCLUDE option to the internally run VSInstr.exe of VS2010.
Do I have to run VSInstr.exe externally in order to exclude a namespace? And if I use it externally, I can not use VS2010 to generate my code coverage, right?
Please let me know if I am missing something.
Thanks.
-Pradnyesh
- Přesunutý Helen Zhao 15. března 2012 3:46 (From:Visual C++ General)
Všechny reakce
-
15. března 2012 3:45
Hi Pradnyesh,
According to your description, I'd like to move this thread to "Visual Studio Unit Testing Forum" for better support, where more experts live.
Thanks for your understanding.
Have a nice day!Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
-
15. března 2012 5:39Moderátor
Hi Pradnyesh,
Thank you for posting in the MSDN forum.
Warning 3/13/2012 12:46:07 PM Instrumentation error while processing file lib_test.exe:
Error VSP1018: VSInstr does not support processing binaries that are already instrumented..Make sure you've got code coverage disabled when running your tests under a performance session. Code coverage and the profiler share the same technology for data collection, and they'll step on each other's toes if they're allowed to run together.
Reference:
http://social.msdn.microsoft.com/Forums/ar/vststest/thread/3c041937-d11e-45e2-a093-8d55b204dc4f
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Označen jako odpověď Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator 21. března 2012 2:52