freeCodeCamp/guide/chinese/software-engineering/code-coverage/index.md

23 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Code Coverage
localeTitle: 代码覆盖率
---
## 代码覆盖率
当您在软件上运行自动化测试以查找错误时, **代码覆盖率**是衡量您测试的代码在测试期间实际执行的程度。
根据定义,在测试期间未执行的代码未经过测试,因此可能包含错误。因此,一般来说,测试套件报告的代码覆盖率越高,错误被忽视的可能性就越小。
这并不是说100的代码覆盖率意味着0的错误几率很容易想象一种情况其中一段代码中的所有可用函数都被调用但不一定是输入代表您可能期望从真实用户那里获得的各种场景。
在您实际使用自动化测试并尝试确保有效地执行此操作之前,代码覆盖范围的详细信息并不重要。
#### 更多信息
[维基百科 - 代码覆盖率](https://en.wikipedia.org/wiki/Code_coverage)
[freeCodeCamp指南 - 测试驱动开发](https://guide.freecodecamp.org/agile/test-driven-development)
[freeCodeCamp指南 - 单元测试](https://guide.freecodecamp.org/software-engineering/unit-tests)
[freeCodeCamp指南 - 持续集成](https://guide.freecodecamp.org/agile/continuous-integration)