我可以使用什么来实现 C#/.NET 的高质量代码覆盖?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/276829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 21:12:01  来源:igfitidea点击:

What can I use for good quality code coverage for C#/.NET?

c#.netcode-coverage

提问by Michael Stum

I wonder what options there are for .NET (or C# specifically) code coverage, especially in the lower priced segment?

我想知道 .NET(或特别是 C#)代码覆盖率有哪些选择,尤其是在价格较低的部分?

I am not looking for recommendations, but for a comparison of products based on facts. I know the following:

我不是在寻找建议,而是基于事实对产品进行比较。我知道以下几点:

采纳答案by David P

I use the version of NCover that comes with TestDriven.NET. It will allow you to easily right-click on your unit test class library, and hit Test With→Coverage, and it will pull up the report.

我使用TestDriven.NET附带的 NCover 版本。它将允许您轻松地右键单击您的单元测试类库,然后点击Test With→Coverage,它将拉出报告。

回答by jalbert

There are pre-release (beta) versions of NCoveravailable for free. They work fine for most cases, especially when combined with NCoverExplorer.

免费NCover预发布(测试版)版本。它们在大多数情况下都能正常工作,尤其是与 NCoverExplorer 结合使用时。

回答by CMS

An alternative to NCover can be PartCover, is an open source code coverage tool for .NET very similar to NCover, it includes a console application, a GUI coverage browser, and XSL transforms for use in CruiseControl.NET.

PartCover是NCover 的替代品,它是一种用于 .NET 的开源代码覆盖工具,与 NCover 非常相似,它包括一个控制台应用程序、一个 GUI 覆盖浏览器和用于CruiseControl.NET 的XSL 转换。

It is a very interesting product.

这是一个非常有趣的产品。

OpenCoverhas replaced PartCover.

OpenCover已取代 PartCover。

回答by Ira Baxter

See the C# Test Coveragetool from my company, Semantic Designs:

请参阅我公司的C# 测试覆盖率工具 Semantic Designs:

It has very low overhead, handles huge systems of files, intuitive GUI, howing coverage on specific files, and generated report with coverage breakdown at method, class and package levels.

它具有非常低的开销、处理庞大的文件系统、直观的 GUI、特定文件的覆盖率,以及在方法、类和包级别生成覆盖率细分的报告。

回答by Ira Baxter

I am not sure what the difference is with the retail NCover, but there is also an NCover project on SourceForgethat is of course open source and free.

我不确定与零售 NCover 有什么区别,但SourceForge 上也有一个 NCover项目,它当然是开源且免费的。

回答by jrista

Code coverage features, as well as programmable API's, come with Visual Studio 2010. Sadly, the only two editions that include the full Code Coverage capabilities are Premium and Ultimate. However, I do believe the API's will be available with any edition, so creating code coverage files and writing a viewer for the coverage info would likely be possible.

代码覆盖功能以及可编程 API 随 Visual Studio 2010 一起提供。遗憾的是,包含完整代码覆盖功能的仅有两个版本是 Premium 和 Ultimate。但是,我确实相信 API 将适用于任何版本,因此创建代码覆盖率文件和编写覆盖率信息查看器可能是可能的。

回答by Mike Two

JetBrains (of ReSharperfame) has been working on a coverage tool for a little while called dotCover. It's showing a great deal of promise.

JetBrains(因ReSharper出名)一直致力于开发一种名为dotCover的覆盖工具。它显示了很大的希望。

回答by Hadi Hariri

We've released EAP to dotCoverand will be releasing the beta version soon.

我们已将 EAP 发布到dotCover,并将很快发布测试版。

回答by sergeb

TestMatrixis a unit test runner and code coverage tool.

TestMatrix是一个单元测试运行器和代码覆盖率工具。

回答by Minh Cuong Tran

TestCocoonis also pretty nice. It is in active development and has a user community:

TestCocoon也很不错。它正在积极开发中,并拥有一个用户社区:

  • Open source (GPL 3)
  • Supports C/C++/C# cross platform (Linux, Windows, and Mac)
  • CoverageScanner - Instrumentation during the Generation
  • CoverageBrowser - View, Analysis and Management of Code Coverage Result
  • 开源 (GPL 3)
  • 支持 C/C++/C# 跨平台(Linux、Windows 和 Mac)
  • CoverageScanner - 生成期间的检测
  • CoverageBrowser - 代码覆盖率结果的查看、分析和管理

However, TestCocoon is no longer developed and its creators are now producing a commercial software for C/C++.

然而,TestCocoon 不再被开发,它的创建者现在正在为 C/C++ 生产商业软件。