none
Excluding external libraries from Code Coverage in VS2010

    Dotaz

  • 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)
    13. března 2012 20:48

Odpovědi

Všechny reakce