我应该使用代码覆盖率工具吗?
我有兴趣在我的下一个 .NET 项目中使用代码覆盖率工具,但想知道它对我来说是否有必要? 我是我工作的公司中唯一的开发人员,那么使用 NCover 对我有好处吗?还是只适用于使用持续集成的大型团队? 谢谢
I'm interested in using a code coverage tool for my next .NET project but was wondering if it is necessary for me? I'm the only developer in the company I work for, so would using NCover be a benefit to me or is it just for large teams using continuous integration? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我想说,去吧。 分析代码覆盖率甚至可以帮助单个开发人员,甚至可能比团队更有帮助,因为你基本上承担了整个系统的责任。 如果您是唯一的开发人员,您可以完全控制您使用的工具以及您想要的设置方式。 一旦/如果添加更多开发人员,您将拥有创建高质量软件的所有工具。
I would say go for it. Analyzing code coverage can help even a single developer, maybe even moreso than a team, since you basically have the whole system on your shoulders. If you're the only developer, you have full control over what tools you use, and how you want things setup. Once/if more developers are added, you'll have all the tools in place to create quality software.
如果努力编写自动化测试,那么一定要使用代码覆盖率工具来了解这些测试如何覆盖代码库的哪些区域。
在编写测试时查看代码覆盖率也有助于确保您的测试实际上正在测试您认为的内容。
与当今编写测试的开销相比,测量代码覆盖率的开销是如此之小,以至于编写测试然后不查看这些测试的覆盖率是没有意义的。
If go to the effort to write automated tests, then definitely use a code coverage tool to get an idea about how which areas of the code base those test cover.
Viewing code coverage as you write tests is also helpful in ensuring that your tests are actually testing what you think they are.
The overhead of measuring code coverage compared with the overhead of writing tests theses days is so small, that it doesn't make sense to write tests, and then not view the coverage of those tests.
Caleb,
如果您还不知道,VS2008 的 Visual Studio 2008 Team System 版本可以为您执行代码覆盖率。 它不像 NCover 那样全面,但对您来说应该是一个很好的开始。 如果你喜欢它的功能并且想要更多的花哨功能,那么我不明白为什么不。 (我上次查看的时候,经典版只要 200 美元)。
-合作社
Caleb,
In case you don't already know, Visual Studio 2008 Team System Editions of VS2008 can do code coverage for you. It's not as comprehensive as NCover, but it should be a great start for you. If you like what it does and you want more bells and whistles, than I don't see why not. (It's only $200 for the classic edition the last time I checked).
-Artel
当然你应该使用它。 它始终是另一个可以帮助您的工具。
但请记住,在测试代码时,代码覆盖率并不是最重要的事情。
您将获得许多包含测试的代码行,但这并不意味着您的代码在那里是防错的。 使用 ncover 查找覆盖范围很小或没有覆盖的地方。
Of course you should use it. It's always another tool to help you.
But remember, code coverage isn't the most important thing when testing your code.
You will get a number of lines of code that are covered with tests, but that doesn't mean that your code is bugproof there. Use ncover to find places that have little or no coverage.