# Coverage.py 警告: 未收集到数据。(no-data-collected)
警告: 生成报告失败: 无数据可报告。

- **ID:** `python/pytest-coverage-subprocess-not-measured`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试生成子进程（例如通过 subprocess.run 或 multiprocessing），覆盖率未传播到子进程，因此仅测量父进程，而父进程通常没有执行任何行。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.4.x | active | — | — |
| 7.5.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   # .coveragerc
[run]
concurrency = multiprocessing
parallel = true

# conftest.py
import coverage
coverage.process_startup()

# env
COVERAGE_PROCESS_START=.coveragerc
   ```
2. **** (88% 成功率)
   ```
   coverage run --concurrency=multiprocessing -m pytest tests/
coverage combine
coverage report --fail-under=85
   ```

## 无效尝试

- **** — If the tests themselves only spawn subprocesses, the parent process executes no application code and coverage stays empty. (85% 失败率)
- **** — Only affects where data is written, not whether subprocesses are instrumented; the child still does not start coverage. (80% 失败率)
