本文介绍了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:55