目前,当我运行代码覆盖率分析时,报告的覆盖率是 90%。关键是另外10%是实际测试的代码!
如何让 VS 忽略该测试代码,只考虑实际代码?
最佳答案
您可以在您的项目中添加一个运行设置文件。
在该文件中,您可以提及需要从代码覆盖范围中排除的 DLL 名称:
<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和 This page应该为您提供有关如何为单元测试添加和配置 runsettings 文件的更多详细信息。
希望对您有所帮助。
关于c# - 如何让 VS 忽略 Test dll 的代码覆盖率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54402661/