本文介绍了runsettings.xml文件不适用于dotnet测试覆盖率命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下命令为我的一个项目生成覆盖率报告:

I am trying to generate coverage report for one of my project using following commands:

dotnet test "testproject.csproj" /p:CollectCoverage=true /p:CoverletOutputFormat=\"cobertura,lcov\" /p:CoverletOutput="D:\coverage" --settings "runsettings.Runsettings"

我在runsettings.Runsettings文件中提供了以下设置:

I have given following settings in my runsettings.Runsettings file:

       <CodeCoverage>
         <ModulePaths>
          <Include>
            <ModulePath>.*WCController.dll</ModulePath>
          </Include>
         </ModulePaths>
        <!-- We recommend you do not change the following values: -->
         <UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
         <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
         <CollectFromChildProcesses>True</CollectFromChildProcesses>
         <CollectAspDotNet>False</CollectAspDotNet>
      </CodeCoverage>

但是当我运行此命令时,它显示

but when I run this command it is displaying

如您所见,我仅指定包含* WCController.dll程序集,但仍显示其他程序集的范围.

As you can see that I specified only to include *WCController.dll assembly but still it is showing coverage of other assemblies as well.

请帮助我找到此问题的确切原因,因为我不希望在我的承保范围报告中添加任何其他程序集.

Please help me find the exact reason of this issue beacuse I don't want any other assembly in my coverage report.

推荐答案

,您可以添加排除"在您的包含"之后阻止.像这样:

you can add an "exclude" block after your "include." Something like this:

<ModulePaths>
  <Include>
     <ModulePath>.*WCController.dll</ModulePath>
  </Include>
  <Exclude>
     <ModulePath>.*WCController.*.dll</ModulePath>
     <ModulePath>.*WCControllerTests.*.dll</ModulePath>
     ...
  </Exclude>
</ModulePaths>

这篇关于runsettings.xml文件不适用于dotnet测试覆盖率命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 21:54