我可以使用什么来实现 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
What can I use for good quality code coverage for C#/.NET?
提问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:
我不是在寻找建议,而是基于事实对产品进行比较。我知道以下几点:
- NCover
- Seems to be very popular and looks quite good
- Supports statement coverage and branch coverage
- $480 for "NCover 3 Complete"
- Older beta versions are available for free
- Visual Studio (2008 Pro) | (2005 Team System (Development, Test or Team Suite Editions))
- Well, it's Microsoft so I'd expect it to work properly
- Fully integrated into Visual Studio
- At least $5,469
- PartCover- no further development (moved to OpenCover)
- Open source
- Supports statement coverage
- OpenCover- successor to PartCover
- OpenSource
- Supports branch and statement coverage
- 32 and 64 bit support
- Silverlight support
- Background
- Tutorial on The Code Project by the primary developer
- No .NET Core support yet
- SD Test Coverage
- Works with 32 and 64 bits, full C# 4.0
- Handles both small and very large code bases
- $250 for single user license
- JetBrains dotCover
- $100 for Personal License. Free for user groups, open source projects, students and teachers.
- Supports statement coverage
- Silverlight support
- $159 for personal license
- $289 for commercial seat license
* Free during beta, to become commercial, pricing unknownfuture unknown. - Code coverage indicators in Visual Studio
- Continuous (near real time) testing
- Visual per-test code coverage
- Performance metrics, parallel multi-core test execution
- $410for developer license
- NDepend can import coverage data from NCover, DotCover, Visual Studio 2017; 2015, 2013, 2012, 2010 and 2008 Code Coverage files.
- Dependency graph
- Dependency structure matrix
- Visualizing code metrics
- Validating code rules
- 封面
- 似乎很受欢迎,看起来相当不错
- 支持语句覆盖和分支覆盖
- “NCover 3 Complete” 480 美元
- 较旧的测试版可免费获得
- Visual Studio (2008 专业版) | (2005 Team System(开发、测试或团队套件版本))
- 嗯,是微软,所以我希望它能正常工作
- 完全集成到 Visual Studio
- 至少 5,469 美元
- PartCover- 没有进一步开发(移至 OpenCover)
- 开源
- 支持语句覆盖
- OpenCover- PartCover 的继承者
- 开源
- 支持分支和语句覆盖
- 32 位和 64 位支持
- Silverlight 支持
- 背景
- 主要开发人员编写的代码项目教程
- 没有.NET核心还支持
- SD 测试范围
- 适用于 32 位和 64 位,完整的 C# 4.0
- 处理小型和超大型代码库
- 单用户许可证 250 美元
- JetBrains dotCover
- 个人许可证 100 美元。用户组、开源项目、学生和教师免费。
- 支持语句覆盖
- Silverlight 支持
- 个人许可证 159 美元
- 商业席位许可证 289 美元
* 测试期间免费,变为商业版,定价未知,未来未知。 - Visual Studio 中的代码覆盖率指标
- 连续(近实时)测试
- 可视化每测试代码覆盖率
- 性能指标、并行多核测试执行
- 开发者许可证410 美元
- NDepend 可以从 NCover、DotCover、Visual Studio 2017 导入覆盖数据;2015、2013、2012、2010 和 2008 年代码覆盖率文件。
- 依赖图
- 依赖结构矩阵
- 可视化代码指标
- 验证代码规则
采纳答案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
回答by Hadi Hariri
回答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++ 生产商业软件。