How can I disable code coverage / assembly instrumentation in Visual Studio 2012?
Asked Answered
A

2

2

I have a project upgraded from Visual Studio 2010 to 2012 and the .testrunconfig file was included in the upgrade process.

I noticed that it was possible to click "Analyze code coverage" on any of the unit tests that I had run and it would correctly display the result. However, my test run configuration (originally from VS 2010) had code coverage disabled.

After doing a bit of research I learned that the VS 2010 configuration files have been deprecated and replaced by .runsettings files. It would appear that VS 2012 enforces assembly instrumentation by default which has a massive overhead associated with it.

Therefore, I would like to know how I can disable code coverage in VS 2012. Based upon my current findings it does not seem to be a trival task. One recent article I read had me creating an XML file manually and naming it "MYCONFIGURATION.runsettings" and manually manipulating XML attribute values.

Does anyone know how this should be done?

Aylmar answered 9/11, 2012 at 3:45 Comment(2)
Yes, you should add a runsettings file. You can find detailed information at msdn.microsoft.com/en-us/library/jj159530.aspx .Rhizomorphous
Thanks for your response. The research I had originally done led me down the path of the runsettings file. It seems extremely odd that code coverage is enabled by default and there is no simple GUI operation that can be done in VS2012 to disable it. Code coverage/instrumentation is an extremely "expensive" build operation so it surprises me why Microsoft would have enabled it by default. It's almost as though they want you to use NUnit instead :)Aylmar
N
0

This is what I understand from your post:

  • You have a Test project with .testsettings file. You have not enabled code coverage in the test settings.

Code coverage instrumentation is not enabled by default in your scenario. Binaries will be instrumented if you do 'analyze code coverage' from VS.

Additional Info: You can confirm that .coverage file is not generated by running the following command from visual studio developer command prompt:

vstest.console.exe /Settings:<your test settings file> test.dll

A coverage file will only get generated if you have enabled coverage in test settings.

Nobles answered 12/11, 2012 at 6:59 Comment(0)
C
-1

Code coverage is only enabled through the Test Explorer using data driven adapters. The metadata for tests ran through the test explorer is almost completely different than that of tests ran straight from the unit test session window. Have you tried simply running it straight from the code (the MSTest gui bubbles) or from the unit test session window?

Clerihew answered 9/11, 2012 at 3:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.