如何使VS忽略测试dll的代码覆盖率 [英] How to make VS ignore code coverage for Test dll

查看:84
本文介绍了如何使VS忽略测试dll的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,当我运行代码覆盖率分析时,报告的覆盖率是90%.事实是,另外10%是实际测试的代码!

Currently, when I run code coverage analysis the reported coverage is 90%. The thing is that the other 10% is the code for the actual test!

我如何使VS忽略该测试代码,而仅考虑实际代码?

How can i make VS ignore that test code and only take into account the actual code?

推荐答案

您可以在项目中添加运行设置文件.

You can add a runsettings file in your project.

在该文件中,您可以提及需要从代码覆盖范围中排除的DLL名称:

In that file you can mention DLL names which needs to be excluded from code coverage:

<ModulePaths>
  <Include>
    <!-- Include all loaded .dll assemblies (but not .exe assemblies): -->
    <ModulePath>.*\.dll$</ModulePath>
  </Include>
  <Exclude>
    <!-- But exclude some assemblies: -->
    <ModulePath>.*\\Fabrikam\.MyTests1\.dll$</ModulePath>
    <!-- Exclude all file paths that contain "Temp": -->
    <ModulePath>.*Temp.*</ModulePath>
  </Exclude>
</ModulePaths>

此页面

This page and This page should give you more details on how to add and how to configure runsettings file for unit tests.

希望这对您有所帮助.

这篇关于如何使VS忽略测试dll的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆