gpt4 book ai didi

c# - 使用 .runsettings 文件时,代码覆盖率中不包含异步方法

转载 作者:行者123 更新时间:2023-11-30 19:15:43 26 4
gpt4 key购买 nike

每当我在没有指定测试设置文件的情况下对我的解决方案运行 Visual Studio 2015 代码覆盖率时,我测试过的所有异步方法都会包含在覆盖率结果中并适当着色:

enter image description here

但是,当我包含一个 .runsettings 文件时,异步方法不再包含在 Coverage 结果中并且保持未着色:

enter image description here

据我所知,.runsettings 文件中没有任何内容会忽略异步方法:

<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>

<!-- Match assembly file paths: -->
<ModulePaths>
<Exclude>
<ModulePath>.*xunit.*</ModulePath>
</Exclude>
</ModulePaths>
<!-- Match attributes on any code element: -->
<Attributes>
<Exclude>
<!-- Don't forget "Attribute" at the end of the name -->

<Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.Runtime\.CompilerServices.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>

<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>

</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>

我是否缺少我的 .runsettings 文件中的某些内容以使其正常工作?

最佳答案

结果是行

<Attribute>^System\.Runtime\.CompilerServices.CompilerGeneratedAttribute$</Attribute>

导致异步方法未包含在代码覆盖范围内。

关于c# - 使用 .runsettings 文件时,代码覆盖率中不包含异步方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34216137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com