您实际成功使用了哪些技术来提高代码覆盖率? [英] What techniques have you actually used successfully to improve code coverage?

查看:305
本文介绍了您实际成功使用了哪些技术来提高代码覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用TDD来实现100%的库覆盖率,但并非总是如此,而且似乎总是遗留有部分应用程序未经测试和发现.
在某些情况下,当您从遗留代码开始时,该遗留代码几乎没有测试,而且覆盖率也很小.

I regularly achieve 100% coverage of libraries using TDD, but not always, and there always seem to be parts of applications left over that are untested and uncovered.
Then there are the cases when you start with legacy code that has very few tests and very little coverage.

请说明您的情况以及至少在改善范围内有效的方法.
我假设您是在单元测试期间测量覆盖率,但请说是否要使用其他技术.

Please say what your situation is and what has worked that at least improved coverage.
I'm assuming that you are measuring coverage during unit testing, but say if you are using other techniques.

推荐答案

删除代码.

这不是狡猾,但实际上很严重.每当我看到最少数量的代码重复甚至是我无法执行的代码时,我都将其删除.这样可以增加覆盖范围并提高可维护性.

This isn't snarky, but actually serious. Any time I would see the smallest amount of code duplication or even code that I couldn't get to execute, I deleted it. This increased coverage and increased maintainability.

我应该注意,这更适用于增加旧代码库与新代码库的覆盖范围.

I should note that this is more applicable to increasing the coverage of old code bases vs. new code bases.

这篇关于您实际成功使用了哪些技术来提高代码覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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