单元测试词汇:“覆盖率”

发布于 2024-09-18 12:12:40 字数 330 浏览 8 评论 0原文

我正在准备一些有关单元测试的教育/培训材料,并想仔细检查一些词汇。

在我使用的示例中,开发人员测试了Facade全部 可能的输入,但尚未测试其“背后”的更细粒度的单元。

鉴于测试涵盖了整个输入范围,人们还会说测试具有“全面覆盖”吗?我觉得“完全覆盖”通常用于表示代码/单元的覆盖...但是在测试所有可能的输入时肯定会有完整的某些

我要找的另一个词是什么?

I'm preparing some educational/training material with respect to Unit Testing, and want to double check some vocabulary.

In an example I'm using the developer has tested a Facade for all possible inputs but hasn't tested the more granular units 'behind' it.

Would one still say that the tests have "full coverage" - given they cover the entire range of inputs? I feel like "full coverage" is generally used to denote coverage of code/units... but there would certainly be full something when testing all possible inputs.

What's the other word I'm looking for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

救星 2024-09-25 12:12:40

如果所有可能的输入都不能提供 100% 的代码覆盖率,则您拥有 100% 的场景覆盖,但不是完整的代码覆盖率

在这一点上,如果您有 100% 的场景覆盖率而没有完整的代码覆盖率,那么您就有死代码,您应该认真思考它为何存在。

If all possible inputs don't give you 100% code coverage, you have 100% scenario coverage, but not complete code coverage.

On that note, if you have 100% scenario coverage without full code coverage, you have dead code and you should think real hard about why it exists.

愛上了 2024-09-25 12:12:40

如果您决定使用“完全覆盖”,那么您可能会遇到麻烦,因为大多数谈论覆盖率的文献(实际上,还有测量覆盖率的工具)都谈论在所有测试之后在测试代码中执行的代码行正在运行。

您提出的测试用例据说覆盖了函数的域(假设函数至少是一对一,它们也将覆盖该范围)。

If you decide to use 'full coverage' then you might have troubles because most literature that speaks about coverage (and indeed, the tools that measure coverage as well) talk about the lines of code that are executed in the code under test after all tests are run.

The test cases that you propose would be said to cover the domain of the function (and assuming a function that is at least 1-to-1, they will cover the range as well).

白首有我共你 2024-09-25 12:12:40

它是所涉及类的完整代码覆盖率,但显然不是完整的系统源代码。工具可以在不同层面上实现这一点。

请注意,它不能保证代码是正确的,因为它可能错过了需要完全处理的场景(在测试代码和功能代码中)。此外,测试可能会触发所有代码路径并且无法正确断言。

it is full code coverage of the involved classes, but clearly not of the full system source. Tools can give this at different level.

note that it doesn't guarantee the code is correct, as it might have missed an scenario that needs to be handled altogether (both in test and feature code). Additionally the tests could trigger all code paths and not be asserting correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文