如何在不使用 Visual Studio 的情况下启用代码覆盖率?
我有 80 多个 VS2010 解决方案,每个解决方案都包含一些单元测试项目。
在构建过程之前,所有解决方案都会合并为一个大解决方案。
所有测试(或某些测试子集)都在成功构建后执行。
我想为所有测试启用测试代码覆盖率,以获得所有输出程序集的准确代码覆盖率。
我的问题是:如何在不使用 Visual Studio 的情况下启用代码覆盖率?
注意:我正在使用 TFS2010 (MSBuild) 构建合并的解决方案。 VS 2010 Premium 安装在构建服务器上。 MSTest 用于测试执行。
I have 80+ VS2010 solutions, each contains some unit test projects.
All solutions are merged into one big solution before build process.
All tests (or some test subset) are executed after the successful build.
I want to enable test code coverage for all tests to get exact code coverage for all output assemblies.
My question is: how to enable code coverage without using Visual Studio?
Note: I'm using TFS2010 (MSBuild) to build merged solution. VS 2010 Premium is installed on the build server. MSTest is used for test execution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 JetBrain 的 TeamCity Professional。它是一个 CI 服务器,支持执行单元测试和计算代码覆盖率。 小型安装是免费的。
You can use JetBrain's TeamCity Professional. It is a CI server that supports executing unit tests and calculating code coverage. It is free for small installations.
我认为您需要考虑部署代码覆盖率工具,请参阅此处进行比较(前提是您实现了 .net)。
我们使用 NCover,它集成在我们的 TFS 中-建立在它的控制台变体,虽然设置它并不简单,但我们对它非常满意。
在 这篇文章我简要描述了我们如何在构建中插入 NCover,即使您使用其他工具,这也可能对您有用。
I think you need to consider deploying a code coverage tool, see here for a comparison (provided you implement .net).
We use NCover, which integrated in our TFS-Build in it's console variant and, although it's not trivial to set it up, we 're very satisfied with it.
In this post I had briefly described how we inserted NCoverin our build, this might we useful to you even if you go with another tool.
如果您在大型解决方案中创建 Vsmdi 文件(ms test 通常会为您执行此操作),您可以使用它来告诉构建您想要检测哪些程序集。
这只会为针对其运行测试的程序集提供代码覆盖率。如果您使用 testrun.config 文件来决定要运行哪些测试,这应该就是您所需要的。然后,代码覆盖率结果应发布到构建放置位置
编辑:
这篇博文 看起来涵盖了设置代码覆盖率
If you create a Vsmdi file in your large solution (ms test will usually do this for you) you can use this to tell the build which assemblies you want to instrument.
This will only provide code coverage for assemblies that have tests run against them. If you're using testrun.config files to decide which tests you want to run, this should be all you need. The code coverage results should then be published to the build drop location
Edit:
This blog post looks like it covers setting up code coverage