Excluding test code from deployment and code coverage RRS feed

  • Question

  • Hi,

    We have a solution containing two projects: one is a web applications project (WAP) and one is a test project with some UI automation and web tests.
    In our web application project we have a sub-directory with some pages meant specifically for testing some components (tracing, authentication, etc.). My IIS server has its webroot pointed directly to my project source directory, so that I can just build and test in fast iterations.

    My problem is that I'm trying to get code coverage for the web project (by instrumenting the assembly containing the codebehind, as well as other supporting assemblies), but I don't want to get code coverage numbers on the code for the test pages.
    Also, I'd rather not ship the test code in my production assemblies.

    Any tips on how to keep the main code and the test code separate, and also get code coverage only for the main code?

    Friday, February 9, 2007 1:47 AM


  • Hi Julien:

    The instrumentation process will skip over methods marked with the [System.Diagnostics.DebuggerHidden] attribute or the [System.Diagnostics.DebuggerNonUserCode] attribute.  If the methods do not get instrumented, code coverage data will not be collected and they will be omitted from the code coverage results.  Note, however, that the debugger will also respect these attributes.  Unfortunately, you are only able to apply these attributes to methods directly in your code.  The ASP.NET generated methods (FrameworkInitialize, for example) when compiling an .aspx page will not get the attribute applied and will still show up in the coverage results.  We're looking into exposing more filtering options for a future release.  Thank you for your question.


    Peter Huene


    Visual Studio Team Edition for Software Developers

    Thursday, February 22, 2007 9:20 PM