# CoverageWarning: No data was collected. (no-data-collected)

- **ID:** `python/pytest-cov-missing-coverage-data`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The pytest-cov plugin did not detect any code execution during tests, possibly because the test files are not importing the source modules, or the source code paths are misconfigured.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.1.0 | active | — | — |
| 5.0.0 | active | — | — |

## Workarounds

1. **Ensure test files import the source modules that should be covered** (90% success)
   ```
   In your test file, add: from myproject import mymodule
Then run: pytest --cov=myproject tests/
   ```
2. **Specify the source directory correctly in pytest.ini or pyproject.toml** (85% success)
   ```
   Add to pyproject.toml:
[tool.pytest.ini_options]
addopts = "--cov=src"
cov_source = ["src"]
Then run pytest.
   ```

## Dead Ends

- **Reinstalling pytest-cov via pip** — The issue is not with the installation but with the test configuration or code structure. (80% fail)
- **Adding `--cov=myproject` without ensuring the source code is actually executed** — If the tests don't import the source modules, coverage still won't collect data. (60% fail)
