如何在被套覆盖率报告中排除方法?



如何使用coverletreportgenerator从代码覆盖率报告中排除方法。排除.runsettings中的整个命名空间按预期工作,但使用[ExcludeFromCodeCoverage]属性将排除整个文件,而不仅仅是目标方法。请参阅下面的评论,了解我在.runsettings中尝试过的内容。

相关.runsettings行:

<DataCollectionRunSettings>
<DataCollectors>
<DataCollector>
<Configuration>
<Format>lcov</Format>
<Include>[*]*</Include>
<Exclude> 
<!-- excluded namespaces -->
</Exclude>
<!-- excludes entire file from coverage --> 
<ExcludeByAttribute>Obsolete, GeneratedCodeAttribute, CompilerGeneratedAttribute,ExcludeFromCodeCoverage</ExcludeByAttribute>
<!-- included & reported as uncovered --> 
<ExcludeByAttribute> ExcludeFromCodeCoverageAttribute </ExcludeByAttribute>
<SingleHit>true</SingleHit>
<UseSourceLink>true</UseSourceLink>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- included and reported as uncovered -->
<CodeCoverage>
<Attributes>
<Exclude>
<Attribute> ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>

更新:这似乎是最近解决的问题coverlet.更新解决了问题。https://github.com/coverlet-coverage/coverlet/issues/809

只需在方法而不是类上应用[ExcludeFromCodeCoverage]

相关内容

  • 没有找到相关文章

最新更新