How do i exclude a part of the code from a .cs file?  
Author Message
Jesse Cheng





PostPosted: Visual Studio Performance Tools (Profiler), How do i exclude a part of the code from a .cs file? Top

I'm doing unit test on native C++ projects with VSTS 2005.

To get the code coverage of a DLL, I can select the DLL project for instrumentation so the code coverage is purely product code.

However, for code coverage data of a static library, I must select the test project which calls the static library. The code coverage data of test project files are also included.

Is there a way that I can exclude test project from code coverage result for a static library Or put it another way, to get the code coverage of product code only.

Thanks.



Visual Studio Team System12  
 
 
johnls





PostPosted: Visual Studio Performance Tools (Profiler), How do i exclude a part of the code from a .cs file? Top

There are couple possible solutions to the problem.  

One would be if you could place your static library in a DLL for the purposes of unit testing.  The easiest way to do that would be to make a special build which exports all of the classes, methods and data, perhaps using a macro.  This is along the lines of how MFC and ATL sources are built. 

A second option is to make use of the /dumpfuncs and /exclude command line options to vsinstr.exe.  You could first use /dumpfuncs on your test DLL, and then you could construct appropriate /exclude's, perhaps with wildcards, to prevent that code from being instrumented.  This second option is obviously a lot more fragile than the first because you will have to keep the exclude's up-to-date as your unit tests change.

We are considering adding much richer filtering functionality in the Orcas timeframe.

Thanks for using VSTS 2005!



 
 
GauriMK





PostPosted: Visual Studio Performance Tools (Profiler), How do i exclude a part of the code from a .cs file? Top

Hi

Is there a way to exclude a certain part of code from the VSTS Code Coverage tool

Let's say there are 3 functions Add, Subtract and Multiply in my Math.dll (a class library). I dont want to cover Multiply function in my code coverage. Is there any way to achieve this Because when I specify code coverage to be ON; it asks me to specify the dll.

Need a reply urgently!! Thanks in advance.