# Coverage.py 警告: 未收集到数据。(no-data-collected)

- **ID:** `python/pytest-cov-no-data-collected`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest-cov 未收集覆盖率，因为未指定源路径或测试未导入目标模块。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.1 | active | — | — |

## 解决方案

1. **** (98% 成功率)
   ```
   Run: pytest --cov=myapp tests/
Or in pytest.ini:
[pytest]
addopts = --cov=myapp
   ```
2. **** (90% 成功率)
   ```
   Check that test files import the modules under test. Coverage only measures executed code.
   ```

## 无效尝试

- **** — Without a path, coverage may not know which files to measure. (70% 失败率)
- **** — This disables coverage reporting entirely. (90% 失败率)
