MSTest 代码覆盖率 [英] MSTest Code Coverage

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

问题描述

如果我使用 MSTest,有没有办法在 Visual Studio 中测试代码覆盖率?还是我必须购买NCover?

Is there a way to test code coverage within visual studio if I'm using MSTest? Or do I have to buy NCover?

如果 Microsoft 不提供内置工具来进行代码覆盖,NCover Enterprise 是否物有所值,或者旧的测试版是否足够好?

Is the NCover Enterprise worth the money or are the old betas good enough if Microsoft doesn't provide built in tools to do code coverage?

VS 产品描述以及哪些包含代码覆盖率https://www.visualstudio.com/vs/compare/

Description of VS Products and which ones include code coverage https://www.visualstudio.com/vs/compare/

TestDriven.NET (http://testdriven.net/) 如果您的 VS 版本不可用'不支持.

TestDriven.NET (http://testdriven.net/) can be used if your VS version doesn't support it.

推荐答案

是的,您可以从 Visual Studio 中找到代码覆盖率信息,前提是您拥有提供该功能的 Visual Studio 版本,例如 Team System.在 VS.NET 中设置单元测试时,将创建 localtestrun.testrunco​​nfig 文件并将其添加为解决方案的一部分.双击该文件并在对话框左侧找到选项代码覆盖率选项.选择要为其收集代码覆盖率信息的程序集,然后重新运行单元测试.将收集并提供代码覆盖率信息.要获取代码覆盖率信息,请打开测试结果窗口并单击代码覆盖率结果按钮,这将打开一个包含结果的替代窗口.

Yes, you can find code coverage information from within Visual Studio, provided that you have a version of Visual Studio that provides that functionality, such as the Team System. When setting up the unit tests in VS.NET, a localtestrun.testrunconfig file will be created and added as part of the solution. Double-click this file and find the option Code Coverage option on the left of the dialog. Select the assemblies for which you want to collect code coverage information and then re-run the unit tests. Code coverage information will be collected and is available. To get the code coverage information open the test results window and click on the code coverage results button, which will open an alternative window with the results.

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

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