如何在Visual Studio 2012中禁用代码覆盖率/程序集检测?
我有一个从Visual Studio 2010升级到2012的项目,升级过程中包括.testrunconfig文件.
I have a project upgraded from Visual Studio 2010 to 2012 and the .testrunconfig file was included in the upgrade process.
我注意到,可以在我运行的任何单元测试中单击分析代码覆盖率",它可以正确显示结果.但是,我的测试运行配置(最初来自VS 2010)已禁用代码覆盖率.
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.
经过一些研究,我了解到VS 2010配置文件已被弃用,并由.runsettings文件替换.似乎VS 2012默认情况下会强制执行组装检测,这会带来很大的开销.
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.
因此,我想知道如何在VS 2012中禁用代码覆盖.基于我目前的发现,这似乎不是一项艰巨的任务.最近阅读的一篇文章让我手动创建XML文件,并将其命名为"MYCONFIGURATION.runsettings",然后手动操作XML属性值.
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.
有人知道该怎么做吗?
这是我从您的帖子中了解的内容:
This is what I understand from your post:
- 您有一个带有.testsettings文件的Test项目.您尚未在测试设置中启用代码覆盖率.
默认情况下,您的方案中未启用代码覆盖率检测.如果您从VS中分析代码覆盖率",将检测二进制文件.
Code coverage instrumentation is not enabled by default in your scenario. Binaries will be instrumented if you do 'analyze code coverage' from VS.
其他信息: 您可以通过从Visual Studio开发人员命令提示符处运行以下命令来确认未生成.coverage文件:
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.